-2

Im sorry Im a newbie in Ubuntu.

While dpkg can only install, remove, or query individual packages, apt offers additional functionality, such as automatically handling dependencies, retrieving and installing packages from remote locations, and upgrading all installed packages to their latest versions. - https://www.geekbits.io/what-is-the-difference-between-apt-and-dpkg/#:~:text=While%20dpkg%20can%20only%20install,packages%20to%20their%20latest%20versions.

so why do people still use dpkg when there is apt?

  • 3
    Can you show a particular example of people using dpkg, then we might tell you why it's used there in preference to apt? And what is the screenshot supposed to show? Please don't post screenshots of text. Copy the text here instead. – muru Jun 21 '23 at 05:46
  • 2
    apt is a front-end for the dpkg tool.. From the manual (ie. man apt) it'll tell you "apt provides a high-level commandline interface for the package management system" where as dpkg is the actual package manager tool (lower level). Are you actually asking a question though? or wanting this to be a spam header which is what it currently looks like to me. – guiverc Jun 21 '23 at 05:47
  • @muru for example, this https://itsfoss.com/install-chrome-ubuntu/ – user900476 Jun 21 '23 at 05:51
  • besides, why cannot I post a screenshot? it is totally fine on other sites of stackexchange – user900476 Jun 21 '23 at 05:52
  • That one is easy - for years, dpkg was the simplest way to directly install a deb file. See https://askubuntu.com/q/40779/158442. It's only fairly recently (I think maybe 5-6 years or so?) that apt gained the capability to install a local deb file: https://askubuntu.com/a/1324153/158442 – muru Jun 21 '23 at 06:14
  • 4
    @user900476 you can post screenshots of text, but why do you want to post a screenshot of text, when simply copying the text here is easier, and it's easier for everybody to read as well? https://unix.meta.stackexchange.com/q/4086/70524 – muru Jun 21 '23 at 06:15
  • 4
    "besides, why cannot I post a screenshot?" - Because the text in the screenshot cannot be searched. It cannot be copy/pasted by readers. It cannot be read by screenreaders for the visually impaired. It cannot be rendered in a different font for people who want or need that. It won't change colors with styling (such as a dark theme). "it is totally fine on other sites of stackexchange" - Posting images of just text is not acceptable on any of the SE sites. For more info, see this Q&A. – marcelm Jun 21 '23 at 14:31

2 Answers2

9

dpkg is the low-level packaging tool that apt uses to handle packages.

Most "normal" user should only use apt, because it automatically handles dependencies.

Only in very special cases, where you want to install a specific package, and you don't want to automatically resolve dependencies would you use dpkg.

I imagine this would mostly be relevant for troubleshooting and research purposes.

To put it short: If you need dpkg instead of apt, you'll have the insight to know why. If you're not sure, use apt.

And yes, I know some online guides use dpkg - in my opinion, this is a mistake that only causes confusion. The reason is likely (as muru states), that it's only recently that apt got the capability to install local .deb files.

Artur Meinild
  • 26,018
1

If you are literally just installing/updating/removing packages from your system repositories, there is zero reason to ever use dpkg directly, because APT does everything dpkg does (because it actually uses dpkg internally to do it), plus all the stuff that you generally need to do when managing packages that dpkg doesn’t do.

But, APT doesn’t do everything.

The big thing historically that APT did not do was installing DEB packages directly from the package files instead of fetching them from repos (IOW, up until a few years ago you could not apt-get install /some/package/file.deb, you had to use dpkg, or possibly dselect, for that). That limitation is why a lot of older ‘How to install foo on Debian’ type guides often use dpkg instead of APT, and why things like gdebi exist. These days it’s irrelevant though, because you can just pass a package file to APT and it will do the right thing in 99.9% of cases.

The other big thing that often comes up is figuring out which package a given file belongs to or listing the files installed by a package. APT has no options for this (apt-file can technically do it, but that’s not part of APT, is a pain to parse the output of at times, and it only looks at info from the repositories, not the packages themselves, so it does not always work), but dpkg (or, more correctly dpkg-query) provides options to make such lookups.

There are a number of other things APT just doesn’t cover, but just about all of them are only of interest to developers.