How-To Geek

Show the List of Installed Packages on Ubuntu or Debian

While working on the instructions for compiling MonoDevelop from source, I relied heavily on the dpkg and apt-cache commands to tell me what was already installed vs what packages were available in the repository. After completing that article it occurred to me that I should explain how to show what packages are currently installed… so here we are.

The command we need to use is dpkg –get-selections, which will give us a list of all the currently installed packages.

$ dpkg --get-selections
adduser                                         install
alsa-base                                       install
alsa-utils                                      install
apache2                                         install
apache2-mpm-prefork                             install
apache2-utils                                   install
apache2.2-common                                install
apt                                             install
apt-utils                                       install

The full list can be long and unwieldy, so it’s much easier to filter through grep to get results for the exact package you need. For instance, I wanted to see which php packages I had already installed through apt-get:

dpkg --get-selections | grep php
libapache2-mod-php5                             install
php-db                                          install
php-pear                                        install
php-sqlite3                                     install
php5                                            install
php5-cli                                        install
php5-common                                     install
php5-gd                                         install
php5-memcache                                   install
php5-mysql                                      install
php5-sqlite                                     install
php5-sqlite3                                    install
php5-xsl                                        install

For extra credit, you can find the locations of the files within a package from the list by using the dpkg -L command, such as:

dpkg -L php5-gd

Now I can take a look at the gd.ini file and change some settings around…

Lowell Heddings, better known online as the How-To Geek, spends all his free time bringing you fresh geekery on a daily basis. You can follow him on if you'd like.

  • Published 10/8/07

Comments (25)

  1. Thomas Higgins

    Very informative, well written….you have been bookmarked.


  2. KiwiDon

    Just joined and have a lot to learn.
    I think I’ve picked the right place. Cheers KiwiDon.

  3. Glen Wolters

    I cannot get sound, or printer, capability, from desktop computer, since Windows Vista had been installed. How can this problem be corrected?

  4. jd2066

    @Glen Wolters: It’s possible you need drivers for those things. Post your question on the forums along with your computer’s make and model number, printer make and model number and we will try to help you find drivers to fix those things.

  5. fastbullet

    Right you are that the complete list long. In fact, mine was well beyoun a single page.

    What is odd is that I could only scroll through the list from the end up through part of the lib*, but no farther. I really wanted to review what all was already installed. But I hit a brick wall.

    Can anyone tell me why this would be?

    I imagine that if I experiment with pipe-grep-letter -* I may be able to see alphabetic lists…

  6. fastbullet, its not elegant but in a pinch you can redirect anything to a file. (Use greater than > redirect parm)

    dpkg –get-selection > dkpg-get.txt

    That will give you a text file that you can view.

    You are probably aware of adding the | (pipe) more options on any command, granted that will not let you scroll back and forth.

    dpkg –get-selection | more – no scrolling, but you can see everything from beginning to end.

    You will quickly want to learn about grep and awk…just search the terms for plenty of helps. Using grep I can search for any lines that contain a string of characters, for instance if I wanted to find all instances of open* (openssh and openoffice.org3 come to mind and you will probably have a few more). The command with grep would look as follows:

    dpkg –get-selection | grep open*

    That should get you going and give you some additional terms to search for and use. You can get by with grep, but if you really want to do allot, learn shell scripting (bash (Borne shell) and korn (Korn shell) are the most popular, csh (C shell) is another good one, rarely used except by old school system administrators. Ultimately if you really want to manipulate the output of your commands you will want to learn AWK.

    Welcome to GNU/Linux and enjoy the journey, I know you will!

  7. 1fastbullet

    Endless thanks !!

  8. max

    On the same topic, copying packages from one machine to another:

    On source machine:
    dpkg –get-selection | grep -v deinstall > dkpg-get.txt

    On target machine:
    dpkg –clear-selections
    dpkg –set-selections

  9. max

    Ooops, it had to be:

    #source machine:
    dpkg –get-selection | grep -v deinstall > dkpg-get.txt

    #target machine:
    dpkg –clear-selections
    dpkg –set-selections
    apt-get dselect-upgrade

    (You may need to copy /etc/apt/sources.list from source machine to target to let apt-get to download the packages beforehand)

  10. max

    dpkg –set-selections

  11. max

    It looks like forum has problems with the firefox?

    dpkg –set-selections

  12. max

    .. The ‘less’ sign and the text after it got cut, I’ll rephrase:

    cat dkpg-get.txt | dpkg –set-selections

  13. Sam

    Cheers body,

    it was very useful :-)

  14. Sjowhan

    Cheers! Was searching for this helpful document!

  15. niwat

    Oh ! very useful, and thank you very much.

  16. Bimzee

    very useful and thanks a lot geeks

  17. Donald

    Is there a way to expand this to get package descriptions as well? I know that /lib/dpkg/available has a list of all available packages from the last apt-get update with their descriptions. I want to figure out a way to generate a document showing which new packages have been added along with their descriptions to document what has changed on my system. (lenny 5.0.2).

  18. T-Bob

    I thought there was a way to (somehow!) list only the non-default packages – i.e. the ones added after an initial install. Any clues?

  19. Johnny


    to get package descriptions as well use dpkg-query which will gives name,version,description by default but can be customized using dpkg-query -f to show all kinds of things, see man dpkg-query

  20. frenzy

    You can also use:

    dpkg -l
    dpkg –list
    dpkg-query -l
    dpkg-query –list

    This is useful to get more informations about installed packages.

  21. Bryce

    You know, this article is over two years old, and yet its still useful. I needed this information today for a project. Thanks for writing it!

  22. ajaykumar

    Thank you very much to all!

  23. ahiayibor

    Thanks-a-lot. and keep up the good work.

  24. Musa

    Hello All,

    Could anybody kindly tell me how to upgrade a particular installed software?
    for instance, i have installed HAproxy (version 1.3) on ubuntu 10.04 and now i want to upgrade it to version 1.4.
    i have installed HAproxy using terminal command ‘apt-get install haproxy’

    any help here please?


  25. Nitesh

    thanks frenzy you can also try
    ls -f
    ls -a

More Articles You Might Like

Enter Your Email Here to Get Access for Free:

Go check your email!