Thursday, January 04, 2007

Debian package management basics you should know !

For people who shift from the platforms like Fedora, Mandriva to Ubuntu or Debian - Package management is much more pleasant that you would love using it almost everyday.

These are the most basic commands & utilities that I use on my debian based
system (Ubuntu) which will enhance your package management experience even

The commands are


dpkg is at the heart of debian package management system. All the other
programs invoke dpkg which does the package operations and returns the status.

Options of dpkg that I use:

Install a deb package - dpkg -i {packagename}.deb
Remove a deb package - dpkg -r {packagename}
Search for a file in all the installed packages - dpkg -S {name_of_file}
Status of a package - dpkg -s {packagename}


apt-get is a frontend to dpkg and is probably the most packaging command for
debian users. It finds out exactly what the dependencies are, fetches them and
installs them

Options of apt-get that I use:

Install a package and its dependencies - apt-get install {packagename}
Remove a package and its dependents - apt-get remove {packagename}
Update the list of packages - apt-get update
Upgrade the package list - apt-get upgrade
Get the source of package - apt-get source {packagename}


apt-cache is mostly a add-on to help you find new packages :)

Options of apt-cache that I use:

Find all the packages which have {keyword} in name/description - apt-cache search "{keyword}"

apt-cache showpkg {packagename} - same as dpkg -s


apt-file is a nifty command to find out which package a file belongs to

This was covered a few days back - here


Okay, don't like command line? synaptic is a graphical interface for doing all the above :)

Please Note that you will need root access to most of the above commands except for ones where you just check status, etc.

1 comment:

John H said...

My understanding is that aptitude is generally recommended over apt-get these days, as it has better dependency-handling and other useful features (such as logging its operations in /var/log/aptitude).

So instead of apt-get install, you should use aptitude install. Similarly aptitude (dist-)upgrade, aptitude remove etc.

Aptitude's interactive mode takes some getting used to, but is very powerful once you have got to grips with it.

Another useful "apt-cache" command is apt-cache policy, which shows the different versions of a package that are available and their relative priorities.