How To List The Installed Packages on a Debian Based System

December 29, 2009 by
Filed under: command line, HowTo, linux, Ubuntu 

In this tutorial I'm going to show how to list the installed packages on a Debian based operating system, (Debian, Ubuntu, Mint, Sidux, CrunchBang, etc.) I got this gem of a command line one-liner from the Sidux website.

This command is useful if you want to replicate a GNU/Linux installation from one computer to another.

For those who are impatient, I'll cut right to the chase. This command will create a file in your home directory called installed.txt that contains the listing of your installed packages. Open a terminal and enter:

dpkg -l | awk '/^ii/{ print $2 }' | grep -v -e ^lib -e -dev -e $(uname -r) > ~/installed.txt

Let's break down the command to see what the different part do. The first portion,

Affiliate Link
dpkg -l

lists all of the packages in the available repositories, whether they're installed or not. This listing is then pipelined into

awk '/^ii/{ print $2 }'

which filters the list to only those packages that are installed. The list is further filtered by pipelining the output to

grep -v -e ^lib -e -dev -e $(uname -r)

which eliminates package names that begin with "lib", contain "dev", or contain the revision of your currently running kernel. The final portion of the command,

> ~/installed.txt

uses the ">" to redirect the output to your text file.


4 Responses to “How To List The Installed Packages on a Debian Based System”

  1. [...] How To List The Installed Packages on a Debian Based System [...]

  2. Nicolas S says:

    dpkg has a integrated service to provide such a replication.

    You can get a list of installed packages, with option "--get-selections" and set the list to install with option "--set-selections".

    So to replicate an installation you may want to use : "dpkg --get-selections > installed.txt" on the first host and "dpkg --set-selections < installed.txt"

    If you want, you can still add a command to dpkg --get-selections to filter some package as you did.

    • Linerd says:

      @Nicolas - Thanks for the tip! This is what I love about blogging. Post a solution to a problem and someone leaves a comment with an even better way!

  3. Story added...

    This story has been submitted to! If you think this story should be read by the free software community, come vote it up and discuss it here:

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>