Table of Contents
Package management on the command-line (CLI)
Software for Ubuntu is organized via Debian packages. Ubuntu is using the Advanced Packaging Tool (APT) to handle the package management. This page covers how to manage packages without a GUI, directly via command-line interface (CLI).
No GUI? Wait… give it a chance. Using the terminal is really simply an much faster than anything else. You just have to remember 3-4 simple commands, e.g. giving you the power to install or remove many programs at once.
apt-get vs. aptitude
Ubuntu comes without aptitude
since 10.10 Maverick. However, you can install it by using
sudo apt-get install aptitude
There are two wide spread tools for the command-line based upon the Advanced Packaging Tool (APT):
apt-get
aptitude
The battle “apt-get vs. aptitude” is very old and most information you'll find via searchengines is outdated. Therefore I'll list a few actual facts before you are learning anything wrong:
- Newer versions of
apt-get
are nearly as feature rich asaptitude
.apt-get
is able to remove automatically installed dependencies as well asaptitude
. - I personally would not do it, but mixed usage of
apt-get
andaptitude
should be no problem anymore. It is true that both programs are using different databases to keep track of what is why installed, but the programs are aware of this and both should be in sync. If you don't believe me, believe the their maintainers.
- If you don't want to mix: use
apt-get
instead ofaptitude
to make your life easier, at least on Ubuntu:- The default GUI tool Synaptic is a frontend for
apt-get
. - These pretty
apt://
URLs, allowing you to install packages through clicking on a link in your browser, are usingapt-get
.1) - Therefore: if you did not watch out carefully, you may already used
apt-get
instead ofaptitude
.
However, it does not really matter which tool you want to use. Simply choose one. If you are a bad decision maker, take apt-get
. This is especially true since Ubuntu 10.10 Maverick, which does not ship aptitude
per default anymore.
apt-get
Install packages
To install one ore more packages (separated by a space) out of the repositories, use
sudo apt-get install package1 [package2] ...
Needed dependencies are resolved automatically.
Remove packages
To remove one ore more packages, use
sudo apt-get remove package1 [package2] ...
Eventually existing, direct dependencies are are removed automatically.
Eventually unused, indirect dependencies are not removed automatically. If there are any, you can trigger their cleanup via
sudo apt-get autoremove
But this step is optional, for sure.
Update packages
Update your repositories first:
sudo apt-get update
To get the latest versions of the installed packages, run
sudo apt-get upgrade
afterwards.
Tips and tricks
Clean up the cache
apt-get
caches a copy of downloaded packages in /var/cache/apt/archives
. This makes re-installing packages possible without the need for downloading them again. This cache can get really big after using your system a while, use
sudo apt-get clean
to clean it.
Search packages
apt-cache search part-of-the-name
Troubleshooting
aptitude
See also
Weblinks
apturl
which uses apt-get