Debian - How to dpkg

From Linux - Help
Jump to navigation Jump to search
Debian Logo


 /var/lib/dpkg # do not modified if not strictly necessary. 

The file /var/lib/dpkg/status contain all the packages know by dpkg and can be see with:

 grep ^package: /var/lib/dpkg/status | grep package_name

Install with dpkg:

 dpkg -i package.deb

Install all packages from one folder:

 dpkg -R folder


 dpkg -i package.deb  # same if install but package is already installed so the command will update the package instead of install it.

Check if package already installed:

 (dpkg -l zip | grep ^ii > /dev/null) && echo PRESENT | echo ABSENT
 *if return PRESENT = package is already installed
 *if return ABSENT = package is not installed

To update one package only:

 (dpkg -l zip | grep ^ii > /dev/null) && dpkg -l zip.deb

Remove a package:

 dpkg -r package_name

With -r everything is removed, only remain the config files, if need to delete them too use -P for purge

dpkg -rP zip

More option:

 --force-all and --purge will force to delete the package and knowed config files.


How to list all installed package containing the word passwd?

 dpkg -l passwd | grep ^ii

How to get a list of all installed debian packages?

 dpkg --get-selections

How to know what package the file /bin/bash belongs to?

 dpkg -S /bin/bash

What command helps you to know what contains an installed Debian package?

 dpkg -L package
 dpkg request: 

The dpkg data base can be asked easily with the option -l and options:

 -l: list all packages.

Search all installed package with the name apt:

 dpkg -l apt | grep ^ii

Find a file contained in a package:

 dpkg -S /usr/bin/basename

List content of a package:

 dpkg -L coreutils | grep bin

Online resources:

Debian - dpkg