Never Ending Security

It starts all here

Aptitude Commands Cheatsheet

aptitude Command Examples

aptitude is a front-end to the Advanced Packaging Tool (APT). It displays a list of software packages and allows the user to interactively pick packages to install or remove. It has an especially powerful search system utilizing flexible search patterns. It was initially created for Debian, but has appeared in RPM Package Manager (RPM) based distributions as well (such as Conectiva)

aptitude is based on the ncurses computer terminal library, with which it provides an interface that incorporates some elements commonly seen ingraphical user interfaces (GUIs) (such as pull-down menus).

In addition to the ncurses interface, aptitude provides an extensive command-line interface (CLI). Even though aptitude is one executable file, it provides command-line functions similar to those of apt- family of tools (apt-get, apt-cache, apt-listchanges, etc.). Aptitude also emulates most apt-get command-line arguments, allowing it to act as a full replacement for apt-get. In the past, it was recommended that aptitude and apt-get not be used interchangeably. This is no longer true, as both programs now correctly track and share a common list of packages that were automatically installed to satisfy dependencies.

Aptitude-GTK features a graphical front-end using GTK+ and Aptitude-Qt features one using Qt.

Basic Package Install

Aptitude install is used to install packages along with its dependencies.

# aptitude install vim-gtk
The following NEW packages will be installed:
libruby1.9.1{a} libyaml-0-2{a} tcl8.5{a} tcl8.5-lib{a} vim-gtk vim-gui-common{a} 
0 packages upgraded, 6 newly installed, 0 to remove and 317 not upgraded.
Need to get 6,360 kB of archives. After unpacking 19.0 MB will be used.
Do you want to continue? [Y/n/?] y

In the above output, aptitude will display the following:

  • List of all dependent packages that will be installed.
  • Total size of all the packages that will be downloaded, which is helpful to know how much data it will download from the repository.
  • Total disk size required after unpacking the packages.
  • At this stage, if you like to continue the installation, press “y”

Install Specific Version or Multiple Packages

It is also possible to install a particular version of a package. Specify the version number after the “=” sign.

# aptitude install "perl=x.x.x"

You can also install several packages matching a particular pattern as shown below.

# aptitude install ~nxvnc

View Package Information

Get information about a particular package:

# aptitude show vim-gtk
Package: vim-gtk     
State: not installed
Version: 2:7.3.547-6ubuntu5
Priority: extra
Section: universe/editors
Maintainer: Ubuntu Developers 
Architecture: amd64
Uncompressed Size: 2,442 k
Depends: vim-gui-common (= 2:7.3.547-6ubuntu5), vim-common (=
         2:7.3.547-6ubuntu5), vim-runtime (= 2:7.3.547-6ubuntu5), libacl1 (>=
         2.2.51-8), libc6 (>= 2.15), libgdk-pixbuf2.0-0 (>= 2.22.0),
         libglib2.0-0 (>= 2.12.0), libgpm2 (>= 1.20.4), libgtk2.0-0 (>= 2.24.0),
         libice6 (>= 1:1.0.0), liblua5.1-0, libpango1.0-0 (>= 1.14.0),
         libperl5.14 (>= 5.14.2), libpython2.7 (>= 2.7), libruby1.9.1 (>=, libselinux1 (>= 1.32), libsm6, libtinfo5, libx11-6, libxt6,
         tcl8.5 (>= 8.5.0)
Suggests: cscope, vim-doc, ttf-dejavu, gnome-icon-theme
Conflicts: vim-gtk
Provides: editor, gvim, vim, vim-lua, vim-perl, vim-python, vim-ruby, vim-tcl
Description: Vi IMproved - enhanced vi editor - with GTK2 GUI
 Vim is an almost compatible version of the UNIX editor Vi. 

Search for a Package using a Pattern

To list of packages available in configured repository, use search option of aptitude along with the string pattern of the package name.

# aptitude search xvnc
p   linuxvnc           - VNC server to allow remote access to a tty
p   linuxvnc:i386      - VNC server to allow remote access to a tty
p   xvnc4viewer        - Virtual network computing client software for X
p   xvnc4viewer:i386   - Virtual network computing client software for X

Display all Installed Packages

List all installed packages:

# aptitude search '~i' | head
i   account-plugin-aim              - Messaging account plugin for AIM          
i   account-plugin-facebook         - GNOME Control Center account plugin for si
i   account-plugin-flickr           - GNOME Control Center account plugin for si
i   account-plugin-generic-oauth    - GNOME Control Center account plugin for si
i   account-plugin-google           - GNOME Control Center account plugin for si
i   account-plugin-jabber           - Messaging account plugin for Jabber/XMPP  
i   account-plugin-salut            - Messaging account plugin for Local XMPP (S
i   account-plugin-twitter          - GNOME Control Center account plugin for si
i   account-plugin-windows-live     - GNOME Control Center account plugin for si
i   account-plugin-yahoo            - Messaging account plugin for Yahoo!

Advanced Search for Packages

To display only broken packages on the system:

# aptitude search '~b' | head

To find partially uninstalled packages:

# aptitude search '~c'
c   yelp                  - Help browser for GNOME

Display held packages:

# aptitude search '~ahold'
ih  python3 - interactive high-level object-oriented language (default python3 version)

To search for the given keyword in the description:

# aptitude search '~dvim'

Packages under a Section

To list packages under a particular section:

# aptitude search '~sgnome' | wc -l

To display installed package under a section:

# aptitude search '~i~sgnome'| wc -l

Uninstall a Package

To remove an installed package from a system as well as orphaned dependencies, use remove option along with exact installed package name as shown below:

# aptitude remove vim-gtk
The following packages will be REMOVED:  
0 packages upgraded, 0 newly installed, 1 to remove and 317 not upgraded.
Need to get 0 B of archives. After unpacking 2,442 kB will be freed.
(Reading database ... 160189 files and directories currently installed.)
Removing vim-gtk ...
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/vi (vi) in auto mode
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/view (view) in auto mode
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/ex (ex) in auto mode
update-alternatives: using /bin/nano to provide /usr/bin/editor (editor) in auto mode
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/rvim (rvim) in auto mode
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/rview (rview) in auto mode
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/vimdiff (vimdiff) in auto mode
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/vim (vim) in auto mode

Complete Removal of a Package

Use purge option to perform a complete removal. This will uninstall a package as well as orphaned dependencies along with its configuration files

# aptitude purge postgresql

Don’t Update a Package – Hold it

To keep the current version of the package:

# aptitude hold python3

Don’t Update a Package – Keep it

To keep only the current version when there is a scheduled updates for packages:

# aptitude keep perl

keep-all option is to apply the same for all installed packages.

Mark a Package with Install Type

To set the mark as automatic, do the following

# aptitude install package+M


# aptitude install package&M

To set the mark as manual:

# aptitude install package&m

Displays the automatically installed packages count.

# aptitude search '~M~i' | wc -l

Displays the total count for manually installed packages.

# aptitude search '!~M~i' | wc -l

Refresh Available Packages List

To update the list of available package from repositories, do the following:

# aptitude update

Upgrade All Packages – Safe and Full Upgrade

safe-upgrade: To upgrade installed packages to the latest version:

# aptitude safe-upgrade

To prevent from installing new packages then use –no-new-installs as shown below:

# aptitude safe-upgrade --no-new-installs

full-upgrade: To do complete upgrade of all packages:

# aptitude full-upgrade

Clean aptitude Cache

To remove downloaded packages from the cache directory:

# aptitude clean

Use autoclean to remove only the packages from cache which can no longer be downloaded.

# aptitude autoclean

By default, the cache directory is /var/apt/apt/archive

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s