What is the Linux dpkg command?

Overview

Linux is a famous family of open-source Unix-like operating systems. It has its root as the Linux kernel manages a system’s resources, hardware, software memory, etc.

dpkg is a command tool offered by the Linux command line to manage Debian systems packages. It is a command tool for installation, building, removing, and managing Debian-based packages. So, it carries operations for .deb packages through the Linux terminal.

Some command functions of dpkg

1. Check if a package is installed or not

Terminal syntax:

dpkg -S [package name]

To check if a package apache is installed or not using dpkg command, we enter:

dpkg -S apache.deb

If the package is installed, it returns a prompt apache.deb installed. When not installed, it returns apache.deb not installed.

2. List all packages installed in the system

Listing syntax:

dpkg -L

When we enter the above syntax on the command or terminal prompt, every package installed in the system is displayed.

3. List the contents of a single package

Content list syntax:

dpkg --Contents [package name]

To list the contents in the apache package, we enter:

dpkg --Contents apache

Every content of the apache would be listed on the terminal.

4. Remove an already installed package with the dpkg command

Remove syntax:

dpkg -r [package name]

To remove the apache package, we enter:

dpkg -r apache

The above command will remove the apache package from the list of packages in the system.

5. Install a package using the dpkg command

Installation syntax:

dpkg -i [package name]

To install a package apache, we enter:

dpkg -i apache

The above command installs the package apache.

Conclusion

The dpkg command is a tool for Debian systems like Ubuntu. It is used in the terminal prompt to manage and control the resource content of the system.