Saturday, July 11, 2009

dpkg tricks for Ubuntu / debian

http://unixlab.blogspot.com)

In Debian GNU/Linux and its derivatives such as Ubuntu the software packages are bundled in a special format. We generally call them deb packages. A .deb package is basically
an archive of files that you want to install to your computer, plus some header and control
information that identifies the software. The deb files can be manipulated with dpkg command. Here are some common dpkg tricks that you can use in every day life on the Ubuntu/Debian systems.
Let us first get a debian package from Internet. I am using Ubuntu 9.04 for this tutorial and will be using aspell as a demo package. Download aspell from the Jaunty repository.

Installing a package manually.

# dpkg -i aspell_0.60.6-1_i386.deb

Removing the package

# dpkg -r aspell

#dpkg -P aspell ( Removes everything including config files.)

Now Let us explore the contents of a deb package.

Make a temporary directory.

#mkdir aspell_tmp
Extract the deb to the aspell_tmp directory.

# dpkg -x aspell_0.60.6-1_i386.deb aspell_tmp


You can see the package contents.
( Try ls -lR aspell_tmp)

The control information alone can be extrcted using -e flag instead of -x.
Or you can list the contents of a deb package as below.
# dpkg -c aspell_0.60.6-1_i386.deb

You can get details about the package with

#dpkg -p aspell
#dpkg -s aspell

If you find a strange file on your system you can check if it belongs to any package. Let us check the file /usr/share/man/man1/aspell.1.gz ( man page of aspell)
$ dpkg -S /usr/share/man/man1/aspell.1.gz
aspell: /usr/share/man/man1/aspell.1.gz

To see the installed files belonging to aspell try this
# dpkg -L aspell

If the package is not removed completely, you may see some configuration files left over.

No comments: