The dpkg command in Linux is used to manage Debian package files (.deb). It allows users to install, remove, and query information about packages on Debian-based systems, such as Debian, Ubuntu, and their derivatives. The dpkg command works at a lower level than package managers like apt, and it directly interacts with the package management system.
Here’s a table explaining some of the main parameters and options of the dpkg command:
| Parameter | Description |
|---|---|
| -i, –install | Install a new package. |
| -r, –remove | Remove a package. |
| -P, –purge | Remove a package and its configuration files. |
| -l, –list | List installed packages matching a pattern. |
| -s, –status | Show information about a package. |
| -L, –listfiles | List files installed by a package. |
| -p, –print-avail | Show information about an available package. |
| -S, –search | Search for packages matching a given file. |
| –configure | Configure a package that has been unpacked but not yet configured. |
| –unpack | Unpack a package file, but don’t configure it. |
| –audit | Verify the dependencies and unpack status of all installed packages. |
| –get-selections | List package selections for the purposes of later reinstallation. |
| –set-selections | Set package selections using data read from a file generated by --get-selections. |
| –clear-selections | Clear the package selections. |
| –get-selections-pattern | List package selections for packages matching a pattern. |
| –set-selections-pattern | Set package selections for packages matching a pattern. |
Now, let’s see some examples of how to use the dpkg command:
- Install a package:
sudo dpkg -i package.debThis command will install the package stored in package.deb. Note that dependencies may need to be resolved manually.
- Remove a package:
sudo dpkg -r packageThis command will remove the package named package from the system while keeping its configuration files.
- Purge a package:
sudo dpkg -P packageThis command will remove the package named package from the system along with its configuration files.
- List installed packages matching a pattern:
dpkg -l | grep package_patternThis command will list all installed packages whose names match package_pattern.
- Show information about a package:
dpkg -s packageThis command will display detailed information about the package named package.
- List files installed by a package:
dpkg -L packageThis command will list all the files installed by the package named package.
- Search for packages matching a given file:
dpkg -S /path/to/fileThis command will search for the package that provides the file located at /path/to/file.
These are just a few examples of how you can use the dpkg command to manage Debian packages on your system. Always use dpkg with caution, and be careful when removing or purging packages, as it may affect the functionality of the system if done incorrectly.