dpkg: Package management system used on Debian-based distributions
August 9th, 2024 12:55 PM Mr. Q Categories: Command
Command: dpkg
dpkg
is the core package management system for Debian-based distributions (such as Ubuntu and Debian). It provides the basic functionality for installing, configuring, and removing software packages in .deb
format.
Sample Command and Output:
Copy001$ dpkg
Description:
dpkg
: Launches thedpkg
command-line tool, allowing users to manage Debian packages on the system.
Additional Commands and Sample Outputs:
dpkg -i package_name.deb
: Install a.deb
package. Sample Command and Output:
Copy001 $ sudo dpkg -i example-package.deb
002 Selecting previously unselected package example-package.
003 (Reading database ... 123456 files and directories currently installed.)
004 Preparing to unpack example-package.deb ...
005 Unpacking example-package (1.0-1) ...
006 Setting up example-package (1.0-1) ...
007 Processing triggers for man-db (2.9.1-1) ...
Description:
dpkg -i <package_name.deb>
: Installs the specified Debian package.- Installs all files listed in the package into the appropriate locations and registers the package with the package management system.
dpkg -r package_name
: Remove an installed package. Sample Command and Output:
Copy001 $ sudo dpkg -r example-package
002 (Reading database ... 123456 files and directories currently installed.)
003 Removing example-package (1.0-1) ...
004 Processing triggers for man-db (2.9.1-1) ...
Description:
dpkg -r <package_name>
: Removes the specified package from the system but leaves its configuration files.dpkg -P package_name
: Purge a package, including its configuration files. Sample Command and Output:
Copy001 $ sudo dpkg -P example-package
002 (Reading database ... 123456 files and directories currently installed.)
003 Removing example-package (1.0-1) ...
004 Purging configuration files for example-package (1.0-1) ...
005 Processing triggers for man-db (2.9.1-1) ...
Description:
dpkg -P <package_name>
: Completely removes the package and all of its associated configuration files.dpkg -l
: List all installed packages. Sample Command and Output:
Copy001 $ dpkg -l
002 Desired=Unknown/Install/Remove/Purge/Hold
003 | Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
004 |/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
005 ||/ Name Version Architecture Description
006 +++-==============-==============-============-=================================
007 ii example-package 1.0-1 amd64 An example package
008 ii bash 5.0-6ubuntu1.1 amd64 GNU Bourne Again SHell
Description:
dpkg -l
: Lists all installed packages along with their status, version, architecture, and description.dpkg -s package_name
: Display detailed information about an installed package. Sample Command and Output:
Copy001 $ dpkg -s example-package
002 Package: example-package
003 Status: install ok installed
004 Priority: optional
005 Section: utils
006 Installed-Size: 1234
007 Maintainer: Example Maintainer <maintainer@example.com>
008 Architecture: amd64
009 Version: 1.0-1
010 Description: An example package
011 This is an example package used for demonstration purposes.
Description:
dpkg -s <package_name>
: Shows detailed information about the specified installed package, including its status, version, architecture, and description.dpkg -L package_name
: List files installed by a package. Sample Command and Output:
Copy001 $ dpkg -L example-package
002 /.
003 /usr
004 /usr/share
005 /usr/share/doc
006 /usr/share/doc/example-package
007 /usr/share/doc/example-package/README
Description:
dpkg -L <package_name>
: Lists all the files installed by the specified package, including documentation and configuration files.dpkg -S filename
: Search for a package that owns a specific file. Sample Command and Output:
Copy001 $ dpkg -S /bin/bash
002 bash: /bin/bash
Description:
dpkg -S <filename>
: Searches the database of installed packages to find out which package installed the specified file.
Note: dpkg
is a foundational tool for package management on Debian-based distributions, handling the installation, removal, and querying of .deb
packages.