Tag Archives: packages

List of installed packages on Ubuntu

This lists packages added after Ubuntu was installed.

When I upgrade from one version of Ubuntu to another, I do a fresh install. I have a procedure on my personal wiki with all of the steps to move in. Part of that is restoring data from backup, Part is restoring or recreating configuration files.

But what about software packages? There is a baseline of packages that I use all the time, but I also add packages ad hoc as required. It is convenient to get a list of what is installed.

Here’s a one-liner to list installed packages on Ubuntu:

cat /var/log/installer/initial-status.gz | gzip -d | grep '^Package:' | awk '{ print $2}' > tmp.txt && aptitude search -F %p '~i!~M' | awk '{ print $1}' | grep -v -F -f tmp.txt && rm tmp.txt

The list that is returned is pretty good. You can save the output to a text file and edit that file to get the list of packages you want to install on the new system.

Here’s how to output to packages.txt:

cat /var/log/installer/initial-status.gz | gzip -d | grep '^Package:' | awk '{ print $2}' > tmp.txt && aptitude search -F %p '~i!~M' | awk '{ print $1}' | grep -v -F -f tmp.txt > packages.txt && rm tmp.txt

As you can see, it greps out a list of packages included in the original install, grabs the second field with awk and stuffs the result in a temporary file. Then a list of installed packages is generated, again using awk to parse out the package name field. Then grep is used to compare thee two lists and output just the packages installed after initial installation.

Here is what I have installed:


So, this is a list of 40 packages installed on my machine, out of a total of 1560 packages returned by “dpkg –list” (thanks, Mark!). Just those I installed, not everything including all of baseline Ubuntu.

Interactive, Full Screen Aptitude

Debian’s aptitude command is, according to their documentation, the preferred program for package management. I use Ubuntu for my work machine and servers and have found aptitude to be easy to understand and use, as well as reliable.

see also: Aptitude vs Apt-get Comparison

Unlike apt-get, aptitude offers a full-screen (or full-window more likely) mode that can be used to interactively manage packages on a Debian or Ubuntu system. As is often the case, a combination of command line operation and an interactive utility prove to be very attractive and useful.

You might use command line mode most often, to install, remove and upgrade packages, and sometimes use the interactive mode to check the status of your system and mark packages to manage how particular packages are dealt with.

To start in interactive mode, simply enter aptitide, with no subcommands:


note: You do not need to sudo aptitude because, in interactive mode, it will prompt you and run sudo itself, if needed. Oh, the convenience!

Right away, you will see the interactive mode user interface:

Drop-down menus

The interactive interface includes drop-down menus at the top of the display. These are accessed with control-r or F10. Many of the of the commands available have a shortcut command key available, listed on the right side of the menu choice.

A full list of menu commands can be found here: http://algebraicthunk.net/~dburrows/projects/aptitude/doc/en/ch02s01s02.html

Package categories

Packages are shown in groups, organized by the following categories:

category explanation
New packages Packages that have been added since the list of new packages has been cleared (with the f command).
Installed packages Packages that are installed on the computer.
Not installed packages Packages that are not installed on the computer.
Obsolete and locally created packages Packages that are installed on the computer, but not available from an apt source.
Virtual packages Pseudonymous for other packages for compatibility or convenience.
Tasks Groups of packages that offer an easy means to install groups of packages for some purpose.

While the user interface is pretty well designed, it can be tricky to use because a variety of single letter codes are displayed and commands are entered via arcane single letter commands.

Navigation command keys

key action
F10 or control-t Show the drop-down menu
? Show help
Arrow keys Navigation
Enter key Select
+/- keys Mark a package to be installed, updated or removed
g key* Go forward: preview/confirm actions
q key* Go back: quit

* The q command quits the current operation and goes back to the previous mode. When at the top level, the q command quits the program. In general, the g goes forward and the q goes back.

Example workflow

  • press u to update local list of available packages
  • press U to mark upgradable packages
  • press g to review pending actions (modify if desired*)
  • press g (again) to start the process

Press g twice? Yes, the first time results in a list of packages that will be processed and the second time completes the action. This gives you a chance to review the changes before proceeding.

If you’ve erred, you can select ‘Cancel pending actions’ in the ‘Actions’ menu.

*When reviewing pending actions:

  • a explicitly accepts an action (press it again to un-accept).
  • r rejects a pending action.
  • g again goes ahead with pending actions.

Common actions

Use control-t for the drop-down menu to see all available actions. All of these commands are found in the Actions drop-down menu.

shortcut key item in Action menu action
g Install/remove packages Show preview, or if preview visiable, perform actions
u Update package list Update local package list from Internet sources
U Mark Upgradable Flag upgradable packages
f Forget new packages Clear “new” packages list
Q Quit Quit aptitude

Common package commands

These commands are found in the Package drop-down menu.

shortcut key item in Action menu action
+ Install Marks package for installation
- Remove Marks package for removal
i Cycle Package Information Changes information displayed for selected package

Current state flags

These flags appear in the first column of a table of packages when you’ve drilled down in one of the categories.

flag meaning
i Package is installed and all its dependencies are satisfied.
c Package was removed, but its configuration files are still present.
p Package and all its configuration files were removed, or the package was never installed.
v Package is virtual.
B Package has broken dependencies.
u Package has been unpacked but not configured.
C Half-configured: the package’s configuration was interrupted.
H Half-installed: the package’s installation was interrupted.

Position of the Current State and Action flags in the Package lists:

Action flags

These flags appear right after the current state flag in column one of displayed packages when you’ve given a command to make an alteration. One or more action flags will appear.

flag meaning
i Package will be installed.
u Package will be upgraded.
d Package will be deleted: it will be removed, but its configuration files will remain on the system.
p Package will be purged: it and its configuration files will be removed.
h Package will be held back: it will be kept at its current version, even if a newer version becomes available, until the hold is cancelled.
F An upgrade of the package has been forbidden.
r Package will be reinstalled.
B Package is broken: some of its dependencies will not be satisfied. aptitude will not allow you to install, remove, or upgrade anything while you have broken packages.




Aptitude vs Apt-get Comparison

see also: Interactive, Full Screen Aptitude

One of the many attractive features of Ubuntu and Debian Linux is the package management system. Coming from other operating systems and other distributions makes the discovery of the Advanced Packaging Tool, APT, a source of pleasure and delight. Here is a system that solves dependency hell, makes keeping soft up to date easy and facilitates simple installation and removal of software packages.

The mainstay of this system has been apt-get, an extremely useful and versatile program that has been the heart of the Debian APT system. A great and useful program, but not perfect, the newer program aptitude is the result of an effort to improve on apt-get. In addition to a cleaner command line interface, aptitude offers a fullscreen character-based UI and more complete tracking of what has been installed and interdependencies.

aptitude is a newer and improved replacement for apt-get

These two programs provides higher level capabilities compared to dpkg, the Debian low-level package management utility. They offer an interface to package repositories and provide relief from dependency hell.

feature apt-get command aptitude command
fullscreen interface N/A aptitude
install package apt-get install ‘pkgname’ aptitude install ‘pkgname’
remove package apt-get remove ‘pkgname’ aptitude remove ‘pkgname’
purge package (removes package
and installation files)
apt-get –purge remove ‘pkgname’ aptitude purge ‘pkgname’
upgrade installed packages apt-get upgrade aptitude upgrade
upgrade installed packages
even if other packages
must be removed
apt-get dist-upgrade aptitude dist-upgrade
show package details (apt-cache show ‘pkgname’) aptitude show ‘pkgname’
search for packages (apt-file ‘searchpattern’) aptitude search ‘searchpattern’
delete installation files 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 ‘pkgname’ aptitude show ‘pkgname’
Retain the current version
of a package going forward
N/A aptitude hold pkgname
Clear the hold on a
package from
‘aptitude hold pkgname’ command
N/A aptitude unhold pkgname
List reverse dependencies apt-cache rdepends packagename aptitude -D packagename
super cow powers apt-get moo aptitude -v[v[v[v[v]]]] moo

As you can see, in addition to a more complete dependency tracking solution, aptitude also provides a (well designed) full-screen interface and cleaned-up command line syntax. Also, contrary to reports elsewhere, aptitude offers the ever important super cow functionality, with sarcasm added (Easter egg).

When installing a package, aptitude will show which other packages, though not required, are recommended or suggested, so you can decide whether or not to also install those.

Because aptitude more completely track dependencies, if you use it exclusively your will not need to use deborphan or debfoster.

Apt-get does not remove packages it installed as dependencies when the package you specified to be installed is removed. Aptitude does remove unneeded dependencies. This basic difference can cause problems when switching from apt-get to aptitude.

Don’t use both apt-get and aptitude interchangeably

Use one or the other. I’ve switched completely from using apt-get to using aptitude. If you do use apt-get, afterward run aptitude and fix any problems detected by first pressing g, which will show broken dependencies and packages that aptitude would remove. If you want to retain the packages that would be removed, arrow down to the header of that category and press the + key. Pressing g again will update your system with your indicated changes.

There is a difference in how aptitude keeps track of installed packages and their dependencies compared to apt-get. Aptitude is more precise is tracking these dependencies. Consequently, when you switch from using apt-get to aptitude, the first time you use aptitude you can run into problems because it can remove needed packages because it does not know that they are needed. This can be resolved through aptitudes’s full-screen interface or by entering the following command:

sudo aptitude keep-all

This will cause aptitude to retain all current packages going forward.

Aptitude’s full-screen interface

As displayed in the comparison table, aptitude offers a character-based full-screen interactive user interface if aptitude is entered as a command with no options.

The interface is very well designed and implemented, logical and easy to use after a few minutes of examination and trial. It has a drop-down menu system, which I found to work well using a mouse. The help system can be access via the drop-down menu or by pressing the ‘?’ key. A plethora of options are presented, most of which will make sense from what you’ve seen in the command line operation of the program. Pressing ‘q’ exits help…indeed pressing ‘q’ is the way to exit other modes in the program and exiting the program itself.

Other thoughts

I’ve found aptitude to be so well done, that I use it for all my package management needs. I use Synaptic to help search for software sometimes, whether for my local machine or a server. Then, I install it with aptitude…in any case Synaptic would be pretty useless over SSH to a server.

Some pages I found helpful: http://pthree.org/2007/08/12/aptitude-vs-apt-get/ and http://www.garfieldtech.com/blog/your-debian-aptitude.