How To List The Installed Packages on a Debian Based System

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,

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 thoughts on “How To List The Installed Packages on a Debian Based System

  1. Pingback: Links 8/1/2010: KDE Software Compilation 4.4 RC1 | Boycott Novell

  2. Nicolas S

    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.

    Reply
    1. Linerd Post author

      @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!

      Reply
  3. Pingback: fsdaily.com

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.