Adminbuntu

Everything for the Ubuntu Server Administrator

User Tools

Site Tools


Sidebar

Server Administration


Server Applications


At the Command Line


Elsewhere


Copyright 2013 Applied Conscious Technologies, LLC

Terms of Agreement

Contact


submit to reddit

package_management

General Administration

Package Management

How to install and remove software from your server using Aptitude

Package management on an Ubuntu Server installation is easy and powerful. Package management includes:

  • Handles dependencies, when one package requires other packages
  • Handles upgrades, when security and other upgrades come available
  • Automatically download needed packages for installation or upgrading
  • Searches for packages

package list: http://packages.ubuntu.com/precise/

aptitude man page: http://manpages.ubuntu.com/manpages/precise/man8/aptitude.8.html

Ubuntu apt howto: https://help.ubuntu.com/community/AptGet/Howto


Apt or Aptitude?

As in life, in Linux you are many choices. For standard package management under Ubuntu, you have the choice of Apt and Aptitude. Both are capable systems and able to find and automatically download packages from repositories.

This site shows the use of Aptitude instead of Apt because of the past experience of the author. Both are great systems, the problem was that Apt updated a server with a package that required unavailable dependencies, leaving the server in a difficult to fix, un-bootable state. This was a couple of years ago and that problem has probably been fixed, and led to a preference of using the Aptitude package manager.

The availability and functionality of the aptitude safe-upgrade option may or may not be duplicated with Apt, but is explicitly available with Aptitude.

This is a preference based on experience and other administrators use the system that they prefer based on their experience or the experience of others.

Update the Local Package Index

To ensure that the local copy of available packages is up to date, enter:

sudo aptitude update

Search for a Package

Use the aptitude search parameter followed by what you want to find.

aptitude search searchterm

Package Information

After finding a package with aptitude search, you can view extensive information about the package with:

aptitude show packagename

Information Shown

  • version
  • dependencies
  • size
  • description
  • homepage
  • much more

Install a Package

sudo aptitude install packagename

Remove a Package

sudo aptitude remove packagename

Upgrading Packages

The safe-upgrade option will upgrade a package only if other packages that are dependent on it use the package's version and packages that are depended on are also the correct version. This prevents upgrading to a version of the package that breaks your system.

sudo aptitude safe-upgrade

List Installed Packages

It is often necessary to know which packages are installed on a server.

  • When preparing to move to a new server
  • To review packages with the goal of removing unused packages
  • To know what is installed as part of a security review
  • When writing a maintenance plan

List packages installed packages on the system:

dpkg --get-selections

dpkg man page: http://manpages.ubuntu.com/manpages/precise/man1/dpkg.1.html

Archive of Installed Packages

The Apt/Aptitude system stores packages that have been installed. This constitutes a record of what has been installed, but does consume disk space. On systems that are tight on disk space, reclaiming disk space may be more important than this data.

View Disk Space Consumed by Installed Packages

du -sh /var/cache/apt/archives

du man page: http://manpages.ubuntu.com/manpages/precise/man1/du.1.html

Remove Archived Packages

Removes the installation files of installed packages to free up disk space.

sudo aptitude clean

Automatic Notification of Available Upgrades

To receive automatic emailed notifications about available package upgrades, install Apticron.

apticron man page: http://manpages.ubuntu.com/manpages/precise/man1/apticron.1.html

sudo aptitude install apticron

Edit Apticron's configuration file:

sudo vi /etc/apticron/apticron.conf

Change the EMAIL line to the email address where notifications should be sent.

EMAIL="root@example.com"

Feature Comparison of Aptitude vs Apt

The preference of Aptitude is not a religious one. This table shows some of what each system can do.

feature apt-get command aptitude command
fullscreen interface N/A aptitude
install package apt-get install packagenameaptitude install packagename
remove package apt-get remove packagenameaptitude remove packagename
purge package (removes package and installation files)apt-get –purge remove packagenameaptitude purge packagename
upgrade installed packages only if inter package versions are correct N/A aptitude safe-upgrade
upgrade installed packages apt-get upgrade aptitude upgrade
upgrade installed packages even if other packages must be removed apt-get dist-upgradeaptitude dist-upgrade
show package detailsapt-cache show packagename aptitude show packagename
search for packagesapt-file searchpattern aptitude search searchpattern
remove archived installed packages apt-get clean aptitude clean
delete obsolete installation files apt-get autoclean aptitude autoclean
update local cache of available packages apt-get update aptitude update
show package details apt-get show packagename aptitude show packagename
retain the current version of a package going forward N/A aptitude hold packagename
clear the hold on a package from ‘aptitude hold packagename’ command N/A aptitude unhold packagename
list reverse dependencies apt-cache rdepends packagename aptitude -D packagename
super cow powers apt-get moo N/A

package_management.txt · Last modified: 2015/05/31 21:20 (external edit)