sudo dpkg --install some_stuff_all.deb

Install the packages in the file some_stuff_all.deb.

sudo dpkg --remove some_stuff_all.deb

Displays the message:

dpkg: error: you must specify packages by their own names, not by quoting the names of the files they come in
Type dpkg-deb --help for help about manipulating *.deb files;

Then this lists the individual files:

dpkg-deb  --contents  some_stuff_all.deb

How does one list the packages in a .deb file?

  • 2
    Is my_stuff_all.deb a deb of debs? Your question seems to imply that the my_stuff_all.deb contains other .deb packages. Is that what you mean? Also, it looks like your last section (dpkg-deb --contents my_stuff_all.deb) answers your question. Could you edit and clarify what you're asking here? – terdon Oct 4 '15 at 23:18
  • 1
    Your question is unclear, but sudo dpkg --remove my_stuff_all.deb doesn't work because you need to specify the package, not the actual deb file. Also, you probably want to use apt-get to remove that package. apt-get remove pkgname, or apt-get purge pkgname. – Faheem Mitha Oct 4 '15 at 23:23
  • So, if you do not know if the file has been renamed how do you determine the name of the enclosed package? – CW Holeman II Oct 4 '15 at 23:52

To get information about a package file:

dpkg -I some_stuff_all.deb

This gives you all available information about the file, including Package:, Version:, Depends:, Description:, etc.

See dpkg --help for a summary of options, and man dpkg for details. Note that -I is actually a dpkg-deb option, but dpkg runs dpkg-deb for you when you give it dpkg-deb options. See dpkg-deb --help and man dpkg-deb too.

| improve this answer | |

There is only one package in a .deb file.

If a package file is named example_1.234.deb, then the package is named example. (At least it usually is. Theoretically someone could rename the file.)

If you want to remove a package using dpkg, you have to use

dpkg --remove example and not dpkg --remove example_1.234.deb

because you want to remove the installed package, not the package file.

| improve this answer | |
  • Is there some requirement or convention as to what the delimiter(s) is/are between the package name and the other junk in the file name? – CW Holeman II Oct 4 '15 at 23:55
  • @C.W.HolemanII In all truth you can have a Debian file named iamthenight.deb and it will work. The usual way (Debian compliant mostly) is package-name_version-debianrevision_architecture.deb, i.e. nginx-full_1.94-1_amd64.deb for the nginx-full binary package, upstream version 1.9.4, first Debian package version, for the amd64 architecture. – Thomas Ward Oct 5 '15 at 0:52
  • 1
    You have to be careful here. There's a package named gcc-4.9 and you don't want to accidentally grab gcc (that's a dummy package which doesn't actually do anything by itself, so uninstalling it accomplishes little). – Kevin Oct 5 '15 at 2:56
  • 1
    The gcc packages does do something - it Depends on specific (usually the latest) versions of both cpp and gcc-x.xx packages, and Suggests: several other packages relevant to compiling software. That's one of the purpose of 'dummy' packages, to make it easy to install a whole suite of related packages just by apt-get installing the dummy. Also for transitioning purposes when a package is renamed. The gcc package is an example of both purposes in one pkg as debian supports multiple versions of gcc installed simultaneously by having gcc-4.1, gcc-4.3, ... gcc-4.9 packages. – cas Oct 5 '15 at 4:19
  • The convention used by Debian derivative Ubuntu is that the example package will have a filename like example_123.45.deb. This allows for something like example-9.99_123.45.deb in which the package name is example-9.99. – Nate Eldredge Oct 5 '15 at 16:07

Assuming your package is named foo.deb, you can get extract the actual name of the package (as well as all the other fields listed in the output of dpkg-deb -I foo.deb) using dpkg-deb with the -f option:

dpkg-deb -f foo.deb Package
  • -f foo.deb Package: extracts the Package field from the foo.deb package;
user@user-X550CL ~/tmp % ls -l
totale 46316
-rw-rw-r-- 1 user user 47425034 ott  5 05:55 foo.deb
user@user-X550CL ~/tmp % dpkg-deb -f foo.deb Package                      

Expanding this, you can remove the package in question directly by using a command substitution running dpkg-deb -f foo.deb Package inside a dpkg -r command:

sudo dpkg -r $(dpkg-deb -f foo.deb Package)
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.