Debian/Ubuntu Tips and Tricks


Debian/Ubuntu Tips and Tricks

How To: APT guide

Posted by chantra on May 13th, 2006

Apt is the debian tool to install, remove and search packages. It is a front-end to the dpkg package manager and offer easy searching, installing ..., by using apt-get and apt-cache.
This Howto will give you the basic commands you need to know for installing, removing, searching package and so on.

1. Searching for packages apt-cache
Let say, I'm looking for xmms plugins, the tool for searching is apt-cache.

:~$apt-cache search xmms plugin

This will output a list of packages and their short description which are related to your search.

2. Getting more Information about a package apt-cache

You can obtain detailled information about a package, such as the version, the maintainer name, the size occupied by the package once it will be installed and a longer description:

:~$apt-cache show package1 package2 ...

3. Installing a package apt-get install
Once you pointed out a package you want to install, you need to type:

:~$sudo apt-get install xmms-status-plugin

You might need to install several package at the same time, in that case simply add any other package one after the other one, separated by a " " (Space).

:~$sudo apt-get install package1 package2 ...

apt-get automatically deals with dependencies, therefore any required package will be installed.

If the package you want to install is already install, you can force the reinstallation by using the --reinstall switch.

:~sudo apt-get install xmms-status-plugin --reinstall

4. Removing packages apt-get remove

There is 2 ways of removing a package:

  1. remove the binaries, doc,...
  2. remove the binaries as well as the configuration file.

For a simple removing type:

:~$sudo apt-get remove package1 package2

For a complete remove:

:~$sudo apt-get remove package1 package2 --purge

5. Update your package database apt-get update

You basically need to update your package manager anytime you want to install new package. Revision, Releases might have changed...


:~$sudo apt-get update

will update the software database but will not upgrade your system.

6. Upgrading your system apt-get [dist-]upgrade

In order to turn you system up-to-date with the latest softwares, you need to upgrade your system.

There is 2 different upgrade available: a simple upgrade and a smart upgrade. The smart approach also handle changing dependencies.

The first call is achieved with:

:~$sudo apt-get upgrade

The smart upgrade with:

:~$sudo apt-get dist-upgrade

7. Resolving conflicts and Broken packages apt-get

Some installation, upgrade might sometime turn wrong. Most of the time a call to:

:~$sudo apt-get -f install

will attempt to correct a system with broken dependencies.

8. Checking for dependencies and reverse dependencies apt-cache

You can get the list of packages a given package depends on:

:~$apt-cache depends package1 package2

as well as a list of packages depending on a given package:

:~$apt-cache rdepends package1 package2

this is called reverse dependencies.

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=""> <s> <strike> <strong>