If you happen to be a Debian or one of its based distros user (like: Ubuntu, Linux Mint, deepin, Elementary OS, Zorin OS, SparkyLinux … etc), you should definitely know the essential uses of dpkg
command.
dpkg
is the software at the base of the package management system in the free operating system Debian and its numerous derivatives.dpkg
is used to install, remove, and provide information about .deb packages. Source
1. Install / Upgrade a “.deb” package:
Short syntax: $ dpkg -i PKG.deb
Long syntax: $ dpkg --install PKG.deb
Example:
$ dpkg -i htop.deb
2. Install all “.deb” packages in a directory:
Short syntax: $ dpkg -Ri DIR
Long syntax: $ dpkg --recursive --install DIR
Example:
$ dpkg -Ri ~/deb-pkgs/
-i
, -A
, --install
, --unpack
and --avail
actions.3. Remove / Uninstall a package:
Short syntax: $ dpkg -r PKG
Long syntax: $ dpkg --remove PKG
Example:
$ dpkg -r htop
4. Completely Remove (Purge) / Uninstall a package:
Short syntax: $ dpkg -P PKG
Long syntax: $ dpkg --purge PKG
Example:
$ dpkg -P htop
5. List all / Individual installed packages:
Short syntax: $ dpkg -l PKG
Long syntax: $ dpkg --list PKG
Example:
List all packages:
$ dpkg -l
$ dpkg -l | less
List individual package(s):
$ dpkg -l coreutils
$ dpkg -l | grep -iE 'coreutils|perl'
$ dpkg -l coreutils perl
$ dpkg -l | grep -i 'lib*'
dpkg
‘s command, it will list it individually. Otherwise, it will list all the installed packages.6. List the installed files from a package:
Short syntax: $ dpkg -L PKG
Long syntax: $ dpkg --listfiles PKG
Example:
$ dpkg -L tmux
7. List the contents of a “.deb” package:
Short syntax: $ dpkg -c PKG.deb
Long syntax: $ dpkg --contents PKG.deb
Example:
$ dpkg -c ranger.deb
8. Find out which package does a particular file belong to:
Short syntax: $ dpkg -S FILE
Long syntax: $ dpkg --search FILE
Example:
$ dpkg -S shred
$ dpkg -S /usr/bin/md5sum
9. Display details about a package:
Short syntax: $ dpkg -p PKG
Long syntax: $ dpkg --print-avail PKG
Example:
$ dpkg -p coreutils
apt-cache show PKG
instead.10. Display a package’s status:
Short syntax: $ dpkg -s PKG
Long syntax: $ dpkg --status PKG
Example:
$ dpkg -s htop
To get more help:
See the manual:
$ man dpkg
Or read it online: dpkg(1)