Debian/Ubuntu Tips and Tricks

Debuntu

Debian/Ubuntu Tips and Tricks

How To: DPKG guide

Posted by chantra on June 6th, 2006

This tutorial will bring you through dpkg, the debian package manager. As I introduce apt, I will now introduce dpkg and show how to search which files are installed by a package, which packages are installed on your system ....

Search packages containing a file:

It happens quite often that you use binaries and want to know which package contains it. Let's take the example of gaim, searching file containing bin/gaim will look like this:

$dpkg -S bin/gaim
gaim: /usr/bin/gaim
gaim: /usr/bin/gaim-send
gaim: /usr/bin/gaim-remote.py
gaim: /usr/bin/gaim-client-example
gaim: /usr/bin/gaim-send-async
gaim: /usr/bin/gaim-notifications-example.py

Getting installed package:

searching for packages intalled on your system which are named gaimsomething is achieved by triggering the following command:

$ dpkg --get-selections 'gaim*'
gaim install
gaim-data install
gaim-dev install
gaim-xmms-remote purge

This actually give you the packages named like as well as their status (install|deinstall|purge), install stands for installed on your system ;), deinstall means that the package has been removed but that the configuration files were kept, and purge means that the package was deinstalled plus all the configuration files coming along with.
Getting installed versions:

When a package is installed on your system, you might want to know which version it is. In the following example, the gaim version is 2.0.0.0beta3 and the debian revision 2ubuntu0, a brief summary of the package comes with as well as the package'state (ii,un,pn..):

$ dpkg -l 'gaim*'
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Installed/Config-files/Unpacked/Failed-config/Half-installed
|/ Err?=(none)/Hold/Reinst-required/X=both-problems (Status,Err: uppercase=bad)
||/ Name Version Description
+++-=========================-=========================-==================================================================
ii gaim 2.0.0beta3-2ubuntu0 multi-protocol instant messaging client un gaim-common (no description available)
ii gaim-data 2.0.0beta3-2ubuntu0 multi-protocol instant messaging client - data files
ii gaim-dev 2.0.0beta3-2ubuntu0 multi-protocol instant messaging client - development files
un gaim-gnome (no description available)
pn gaim-xmms-remote

Getting all files installed by a package:

Once a package is installed, you can get all the files installed by that package by trigerring the following command line:

$dpkg -l gaim

This can be pretty usefull to locate the configuration files of a software.

Getting the status of a package:

Finally, you can get the status of a package with the -s switch, this will output the state of the package along with the list of package it depends on, plus the description of the package.

$dpkg -s gaim

Hope this helps :),

Cheerio

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>