skip navigation

www.Hilands.com


Content:: Debian Package Management with dpkg

Manage Debian Packages
Last Modified: 2014-05-07
The dpkg program will allow you to install, remove, and view the contents of a Debian (.deb) file. If you want to update a kernel in Debian you can download a pre-packaged kernel and install it without having to compile or install a new operating system. Some applications like adobe flash don't exist in the stable Debian package lists as they are not completely free software so you may need to download the Debian file repositories and install it with dkpg. Some programs you may want to use aren't well known or maintained by any of the Debian file repositories and the file may be available by the author, dpkg will allow you to download the application and install it with little trouble.

Dpkg is a command line program and may appear to be complex at first compared to other tools like aptitude or synaptic.

Table of Contents
Installing with dpkg
Installing an application can be done with the --install or -i switch followed by the file name. # dpkg -i <DebianFileName>
# dpkg -i linux-image-2.6.32-5-686_2.6.32-30_i386.deb
Listing installed packages
You can list the debain packages currently installed with the L switch -l. # dpkg -l
A list will show three columns Name, Version and Description.
||/ Name                   Version                Description
+++-======================-======================-============================================================
ii  acpid                  1.0.4-5                Utilities for using ACPI power management
ii  adduser                3.102                  Add and remove users and groups
ii  apt                    0.6.46.4-0.1           Advanced front-end for dpkg
ii  apt-utils              0.6.46.4-0.1           APT utility programs
The listings name can be used to remove packages.
Removing packages with dpkg
Removing an application can be done with the --remove or -r switched followed by the file name or the package name. The -r switch will NOT remove configuration files. # dpkg -r <DebianFileName or DebianPackageName>
# dpkg -r linux-image-2.6.32-5-686_2.6.32-30_i386.deb
If you can't find the package name see below on listing installed packages.

To remove the configuration files too you can use the --purge or -p option. dpkg -p <DebianFileName or DebianPackageName>
dpkg -p less
View the files of a debian package
You can use the -c commend to list the contents of an archive. # dpkg -c zsnes_1.510-2.2+b1_i386.deb
The sample output will look similar to
drwxr-xr-x root/root         0 2010-04-26 15:27 ./
drwxr-xr-x root/root         0 2010-04-26 15:27 ./usr/
drwxr-xr-x root/root         0 2010-04-26 15:27 ./usr/bin/
-rwxr-xr-x root/root   3153348 2010-04-26 15:27 ./usr/bin/zsnes
drwxr-xr-x root/root         0 2010-04-26 15:27 ./usr/share/
drwxr-xr-x root/root         0 2010-04-26 15:27 ./usr/share/doc/
drwxr-xr-x root/root         0 2010-04-26 15:27 ./usr/share/doc/zsnes/
-rw-r--r-- root/root     12837 2007-01-24 16:43 ./usr/share/doc/zsnes/readme.txt.gz
-rw-r--r-- root/root      2821 2007-01-24 16:43 ./usr/share/doc/zsnes/index.txt
-rw-r--r-- root/root     51994 2007-01-24 16:43 ./usr/share/doc/zsnes/history.txt.gz
View the version and status of a debian package
The -s switch will display information about the package including the version, architech, size, description, etc. # dpkg -s less
The sample output will look similar to
Package: less
Status: install ok installed
Priority: standard
Section: text
Installed-Size: 286
Maintainer: Anibal Monsalve Salazar 
Architecture: amd64
Version: 444-4
Depends: libc6 (>= 2.11), libtinfo5, debianutils (>= 1.8)
Description: pager program similar to more
 This package provides "less", a file pager (that is, a memory-efficient
 utility for displaying text one screenful at a time). Less has many
 more features than the basic pager "more". As part of the GNU project,
 it is widely regarded as the standard pager on UNIX-derived systems.
 .
 Also provided are "lessecho", a simple utility for ensuring arguments
 with spaces are correctly quoted; "lesskey", a tool for modifying the
 standard (vi-like) keybindings; and "lesspipe", a filter for specific
 types of input, such as .doc or .txt.gz files.
Homepage: http://www.greenwoodsoftware.com/less/
Run an audit of packages, finding broken packages
The --audit or -C switch will run an audit on the installed packages. # dpkg -C If no output is returned no errors were found.
Other dpkg switches to note
# dpkg -unpack
# dpkg -configure