Warning: Declaration of syntax_plugin_translation::handle($match, $state, $pos, &$handler) should be compatible with DokuWiki_Syntax_Plugin::handle($match, $state, $pos, Doku_Handler $handler) in /home/www/readm3.org/lib/plugins/translation/syntax.php on line 75

Warning: Declaration of syntax_plugin_translation::render($format, &$renderer, $data) should be compatible with DokuWiki_Syntax_Plugin::render($format, Doku_Renderer $renderer, $data) in /home/www/readm3.org/lib/plugins/translation/syntax.php on line 75
os:ubuntu:package-management:package-management-cli - readm3.org - IT wiki

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:

  1. Newer versions of apt-get are nearly as feature rich as aptitude. apt-get is able to remove automatically installed dependencies as well as aptitude.
  2. I personally would not do it, but mixed usage of apt-get and aptitude 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 :lang_de:.
  3. If you don't want to mix: use apt-get instead of aptitude 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 using apt-get.1)
    • Therefore: if you did not watch out carefully, you may already used apt-get instead of aptitude. ;-)

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

FIXME

apt-cache search part-of-the-name

Troubleshooting

FIXME

aptitude

FIXME

See also

1)
to be really correct: they are using apturl which uses apt-get
Print/export
QR Code
QR Code os:ubuntu:package-management:package-management-cli (generated for current page)
Languages
Translations of this page: