Debian Linux apt-get package management cheat sheet

byVivek GiteonMay 9, 2005

Both Debian and Ubuntu Linux provides a number of package management tools. This article summaries package management command along with it usage and examples for you.

apt-get : APT is acronym for Advanced Package Tool. It supports installing packages over internet using ftp or http protocols. You can also upgrade all packages in a single operations, which makes it even more attractive.

dpkg : Debian packaging tool which can be use to install, query, uninstall packages.

Gui tools: You can also try GUI based or high level interface to the Debian GNU/Linux package system. Following list summaries them:

aptitude: It is a text-based interface to the Debian GNU/Linux package system.

i386 : Hardware Platform on which this package will run (i386 == intel x86 based system)

.deb : Extension that suggest it is a Debian package

Remember, whenever I refer .deb file it signifies complete file name, and whenever I refer package name it must be first part of .deb file. For example, when I refer to a package sudo it means sudo only and not the .deb file i.e. sudo_1.6.7p5-2_i386.deb. You can find out debian package name with the following command:

apt-cache search {package-name}
apt-cache search apache

Finally, most of the actions listed in this post are written with the assumption that they will be executed by the root user running the bash or any other modern shell.

apt-get add a new package

Add a new package called samba. The syntax is:

apt-get install{package-name}

To install a package called samba, run:

# apt-get install samba

apt-get remove the package called samba but keep the configuration files

Find out all the Debian package which can be used for Intrusion Detection

Type the following command:

# apt-cache search "Intrusion Detection"

Find out all sniffer packages, run:

# apt-cache search sniffer

Find out if Debian package is installed or not (status)

The syntax is:

dpkg -s {package-name} | grep Status

Example:

# dpkg -s samba| grep Status

List each dependency a package has...

Display a listing of each dependency a package has and all the possible other packages that can fulfill that dependency. You hardly use this command as apt-get does decent job fulfill all package dependencies. The syntax is:

If you run ‘aptitude update’ or ‘aptitude upgrade’ or ‘aptitude install’, it looks and works just like apt-get, with a few enhancements. So there is no learning curve.

2. aptitude sanely handles recommends

A long-standing failure of apt-get has been its lack of support for the Recommends relationship. Which is a problem because many packages in Debian rely on Recommends to pull in software that the average user generally uses with the package. This is a not uncommon cause of trouble, even though apt-get recently became able to at least mention recommended packages, it’s easy to miss its warnings.

Aptitude supports Recommends by default, and can be confgigured to support Suggests too. It even supports installing recommended packages when used in command-line mode.

3. aptitude tracks automatically installed packages

Stop worrying about pruning unused libraries and support packages from your system. If you use aptitude to install everything, it will keep track of what packages are pulled in by dependencies alone, and remove those packages when they are no longer needed.

4. use aptitude as a normal user and avoid hosing your system

Maybe you didn’t know that you can run aptitude in gui mode as a regular user. Make any changes you’d like to try out. If you get into a real mess, you can hit ‘q’ and exit, your changes will not be saved. (aptitude also lets you use ctrl-u to undo changes). Since it’s running as a normal user, you cannot hose your system until you tell aptitude to do something, at which point it will prompt you for your root password.

5. aptitude has a powerful UI and searching capabilities

Between aptitude’s categorical browser and its great support for mutt-style filtering and searching of packages by name, description, maintainer, dependencies, etc, you should be able to find packages faster than ever before using aptitude.

6. aptitude makes it easy to keep track of obsolete software

If Debian stops distributing a package, apt will leave it on your system indefinitly, with no warnings, and no upgrades. Aptitude lists such packages in its “Obsolete and Locally Created Packages” section, so you can be informed of the problem and do something about it.

7. aptitude has an interface to the Debian task system

Aptitude lets you use Debian’s task system as it was designed to be used. You can browse the available tasks, select a task for install, and then dig into it and de-select parts of the task that you don’t want. apt-get has no support for tasks, and aptitude is better even than special purpose tools like tasksel.