dpkg: command not found

The dpkg utility is a low-level system tool to extract, analyze, unpack, install, and remove packages with a .deb extension. The scripts read by dpkg inside each .deb file are important as they give information to the program regarding the packages’ installation, removal, and configuration. The dpkg utility resides at the base of the package management system in Debian-based distributions. The Debian package, dpkg, provides the dpkg utility, as well as several other programs necessary for runtime functioning of the packaging system; namely: dpkg-deb, dpkg-split, dpkg-query, dpkg-statoverride, dpkg-divert, and dpkg-trigger. We can take a glance at the /var/log/dpkg.log file. There are a lot of verbose details about triggers and packages going through varying stages of unpacking and configuration.

if you encounter the below error while running the dpkg command:

dpkg: command not found

you may try installing the dpkg package as per your choice of distribution.

Distribution Command
OS X brew install dpkg
Debian apt-get install dpkg
Ubuntu apt-get install dpkg
Alpine apk add dpkg
Kali Linux apt-get install dpkg
Fedora dnf install dpkg
Raspbian apt-get install dpkg

dpkg Command Examples

1. If we want to see a list of packages on this system, we can use the l option:

$ dpkg -l

2. We can also narrow down our output by filtering the dpkg command:

$ dpkg -l xterm

3. We can verify whether or not a package is installed with –get-selections:

$ dpkg --get-selections

4. We can view the locations in which a package is installed by using the L option.

$ dpkg -L xterm

5. We can search for a particular package in this system by using the s option:

$ dpkg -s apache

6. To install a package, use the -i option with the command:

$ dpkg -i tftp_0.17-18_i386.deb

7. We can also extract the content of a package without installing it. We should use the -x option for this:

$ dpkg -x tftp_0.17-18_i386.deb ./tftp_0.17-18_i386

8. Before we can download any packages and install them using the dpkg utility, we need to know the correct hardware architecture of the system. We can use the dpkg-architecture command:

$ dpkg-architecture

9. We can also garner useful information regarding the purpose of a package. We need to use the dpkg-query command with the -s option here:

$ dpkg-query -s tftp

10. To remove an installed application, use the following:

$ dpkg -r [application name]

11. List contents of a local package file:

$ dpkg -c path/to/file.deb

12. Find out which package owns a file:

$ dpkg -S filename

To get the help instructions for the dpkg command, use the following:

$ dpkg --help 

You can use –help to see the instructions of any command you like. Also, you have the option to use the manual command:

$ man dpkg
Related Post