DPKG Command Examples

Debian Package Management Tool

Managing your system with dpkg


dpkg is the software at the base of the Debian Package Management System. dpkg allows you to install, remove packages and list information about packages. dpkg allows you to work directly with ".deb" files.



dpkg command Description Examples
dpkg -i .deb Package Install the specified package dpkg -i seamonkey-mozilla-build_2.16.1-0ubuntu1_i386.deb
dpkg -R Directory Name Install all Packages recursively from specified location dpkg -R /tmp/seamonkey
dpkg -r packagename Remove Package only dpkg -r htop
dpkg -P packagename Delete specified package including any configuration files dpkg -P htop
dpkg -l List all Packages dpkg-l
dpkg -l packagename List specified package only dpkg -l htop
dpkg -L List installed files from package dpkg -L htop
dpkg -c .deb package List files contained in .deb package dpkg -c seamonkey-mozilla-build_2.16.1-0ubuntu1_i386.deb
dpkg -S file/path Locate package from filename dpkg -S /usr/bin/play
dpkg -p .deb package List Information about specified package dpkg -p dpkg -i seamonkey-mozilla-build_2.16.1-0ubuntu1_i386.deb


Examples of dpkg


Remove a package - dpkg -r package>



john@john-desktop:~/Downloads$ sudo dpkg -r htop
(Reading database ... 769711 files and directories currently installed.)
Removing htop ...
Processing triggers for man-db ...
Processing triggers for bamfdaemon ...
Rebuilding /usr/share/applications/bamf.index...
Processing triggers for desktop-file-utils ...
Processing triggers for gnome-menus ...

List all Packages - dpkg -l



Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                                             Version                                    Description
+++-======================-======================-=====================================================================================================================
ii  accountsservice                                  0.6.15-2ubuntu9.4                          query and manipulate user account information
ii  acidrip                                          0.14-0.2ubuntu6                            ripping and encoding DVD tool using mplayer and mencoder
ii  acl                                              2.2.51-5ubuntu1                            Access control list utilities
ii  acpi-support                                     0.140.1                                    scripts for handling many ACPI events
ii  acpid                                            1:2.0.10-1ubuntu3                          Advanced Configuration and Power Interface event daemon
ii  acroread                                         9.4.2-0natty1                              Adobe Reader
ii  activity-log-manager-common                      0.9.4-0ubuntu3.2                           blacklist configuration for Zeitgeist (assets)
ii  activity-log-manager-control-center              0.9.4-0ubuntu3.2                           blacklist configuration for Zeitgeist (control center integration)
ii  adduser                                          3.113ubuntu2                               add and remove users and groups

List an individual Package - dpkg -l PackageName



john@john-desktop:~/Downloads$ dpkg -l htop
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                   Version                Description
+++-======================-======================-============================================================
ii  htop                   1.0.1-1                interactive processes viewer

Display Package Information - dpkg -p packagename



john@john-desktop:~/Downloads$ dpkg -p htop
Package: htop
Priority: optional
Section: utils
Installed-Size: 180
Maintainer: Ubuntu Developers 
Architecture: i386
Version: 1.0.1-1
Depends: libc6 (>= 2.15), libncursesw5 (>= 5.6+20070908), libtinfo5
Suggests: strace, ltrace
Size: 66078
Description: interactive processes viewer
 Htop is an ncursed-based process viewer similar to top, but it
 allows one to scroll the list vertically and horizontally to see
 all processes and their full command lines.
 .
 Tasks related to processes (killing, renicing) can be done without
 entering their PIDs.
Original-Maintainer: Eugene V. Lyubimkin 
Homepage: http://htop.sourceforge.net

Determine if Package is Installed



john@john-desktop:~/Downloads$ dpkg -s htop | grep -i status
Status: install ok installed

List all files contained in .deb package - dpkg -c .deb package



dpkg -c seamonkey-mozilla-build_2.16.1-0ubuntu1_i386.deb
drwxrwxr-x root/root         0 2013-03-13 04:30 ./
drwxrwxr-x root/root         0 2013-03-13 04:30 ./usr/
drwxrwxr-x root/root         0 2013-03-13 04:30 ./usr/bin/
drwxrwxr-x root/root         0 2013-03-13 04:30 ./usr/share/
drwxrwxr-x root/root         0 2013-03-13 04:30 ./usr/share/applications/
-rw-r--r-- root/root       340 2013-03-13 04:30 ./usr/share/applications/seamonkey-mozilla-build.desktop
drwxrwxr-x root/root         0 2013-03-13 04:30 ./usr/share/pixmaps/
-rw-r--r-- root/root     12796 2013-03-13 04:30 ./usr/share/pixmaps/seamonkey-mozilla-build.png
drwxrwxr-x root/root         0 2013-03-13 04:30 ./opt/
drwxr-xr-x root/root         0 2013-03-08 18:54 ./opt/seamonkey/
-rw-r--r-- root/root       168 2013-03-08 18:54 ./opt/seamonkey/dependentlibs.list
-rwxr-xr-x root/root    471340 2013-03-08 18:54 ./opt/seamonkey/libmozsqlite3.so
drwxr-xr-x root/root         0 2013-03-08 18:54 ./opt/seamonkey/isp/
-rw-r--r-- root/root      1493 2013-03-08 18:54 ./opt/seamonkey/isp/movemail.rdf
-rw-r--r-- root/root       365 2013-03-08 18:54 ./opt/seamonkey/isp/SpamAssassin.sfd

The above is an extract from the output from the "dpkg -c seamonkey-mozilla-build_2.16.1-0ubuntu1_i386.deb". If you have a large .deb package, it may be easier to redirect the output from the command to a temp file: "dpkg -c seamonkey-mozilla-build_2.16.1-0ubuntu1_i386.deb >/tmp/test.txt" or "pipe" the output into the "less" command. "dpkg -c seamonkey-mozilla-build_2.16.1-0ubuntu1_i386.deb | less".


Getting Help with dpkg command - dpkg --help


As always, more information can be found on the "dpkg" command and the various numerous options that are available. You can issue the "dpkg --help" command or "man dpkg" for full details of this command.