Ubuntu – Difference between `dpkg -i` and `apt-get install`


From all the other Q&A (like: What is the difference between dpkg and aptitude/apt-get?) I understand that apt-get is a wrapper over dpkg and provides dependency management.

Assuming I'm installing something that doesn't have any dependencies (or they're also installed at the same time) would there be any difference between installing it using apt-get vs dpkg

E.g. (kinda concrete differences I'm looking for)

  • say dpkg can not download the pkg from somewhere, I must download before starting installation, whereas apt-get will do this on my behalf.
  • dpkg won't configure pkg, it'll only copy files. apt-get will configure too.

Best Answer

dpkg -i installs *.deb packages, which is to say packages you have already downloaded from somewhere. It also configures them, but does not download/install dependencies. You need to have downloaded the binary package file(s) manually from somewhere. There also may be hazards in downloading packages from locations that are not the repositories which your distro had included/enabled by default, since third-party packages can be malicious in nature.

apt-get/aptitude install automatically accesses the repositories and PPAs indexes you enabled, searches for the best candidate, downloads it and all its dependencies and installs and configures them automatically.

Using apt-get install -f, you can automatically install missing dependencies of packages e.g. installed through dpkg -i.