dpkg Command Examples in Linux

The dpkg command is used to manage packages on Debian-derived distributions. Until recently, the most important of the Debian packaging tools and still the primary package management program. Used to install or uninstall packages or as a frontend to dpkg-deb. It includes many different options, some of which are described in the following table.

Option Description
-i {package name} Install the package.
-r {package name} Remove (uninstall) the package.
-l [package name] List information about the specified package; if none provided, list all installed packages.
-s [package name] Report whether the package is installed.

dpkg Command Examples

1. Install a package:

# dpkg -i path/to/file.deb

2. Remove a package:

# dpkg -r package_name

3. List installed packages:

# dpkg -l pattern

4. List a package’s contents:

# dpkg -L package_name

5. List contents of a local package file:

# dpkg -c path/to/file.deb

6. Find out which package owns a file:

# dpkg -S filename

7. Remove a package (does not remove configuration files):

# dpkg -r packagename

8. Remove a package and its configuration files:

# dpkg --purge packagename

Conclusion

To use the dpkg program, you must have the .deb software package available on your system. Often you can find .deb versions of application packages ready for distribution on the application website. Also, most distributions maintain a central location for packages to download.

Related Post