Mastering APT

  • April 22, 2007
  • Avatar for jacob
    Jacob
    Peddicord

Chances are, if you use Debian, Ubuntu, or Freespire, you've heard of it: APT. But what is it?

APT stands for Advanced Packaging Tool, and was developed for the Debian Linux distribution. Basically, it allows you to install anything supported on your system with one line in the terminal.

Most people prefer to use a GUI for this type of thing. Many APT-based distributions also have a GUI for installing and removing applications. This usually is Synaptic. Many other GUI's are also derived from Synaptic: The Update Manager and Add/Remove applications both use it as a backend.

APT, unlike a vanilla RPM distribution, uses things called repositories to find packages you can install. Many of them are turned on by default in a distribution. You can add more yourself, as well as disable any that you don't like.

Most of the time, you can manage your software by using Synaptic, Adept, or another GUI. But what if you boot your system in failsafe mode, and there isn't one?

That is where apt-get, the brains behind everything else, comes in handy.

(Note: This tutorial will not take into account any sudo's or su's that you will need to use in commands. To run these commands as-is, you will be need to be in recovery mode, logged in as root, or you may prefix every command with sudo.)

First of all, let's start with a basic command: updating the repository list. Every time an update is released or you make a change to your repository, you will need to run this command:

apt-get update

The tool will look at your sources, and download them from the servers to check for updates. To upgrade your system, however, requires a different command:
apt-get upgrade

Make sure you do not get the two confused: update refreshes the list of software, upgrade downloads and installs all upgrades available.

Now, let's say you want to install XChat. Commonly, packages can be found as their name in the repository, so the following could be used:

apt-get install xchat

A quick sidenote: If for some reason you want to reinstall a package, just run the install command again as usual.

The install command for the most part is straightforward. But, what if you did not know the exact name? That is where the tool apt-cache comes in.

apt-cache search xchat

will search for all programs with the name or description of XChat, at which point you could then install.

If you decide you do not like XChat, you can remove it as easily as you installed it:

apt-get remove xchat

You now have the skills to survive in the wild world of the terminal to install any program you want. Install responsibly. ;)

Avatar for jacob Jacob Peddicord

Home » Articles »