How to list all installed packages in Ubuntu?

Q: How to list all installed packages in Ubuntu?terminal

A: There are many ways to list installed packages in Ubuntu, one of them are  the two following commands :

$sudo sed -ne '/^Package: (.*)/{s//1/;h;};/^Installed-Size: (.*)/{s//1/;G;s/n/ /;p;}' /var/lib/dpkg/status | sort -rn



$sudo  dpkg-query -Wf  '${Installed-Size}t${Package}n' | sort -n


Both commands tested and are working.


{module user9-footer|none}

  • Anonymous

    Just use:
    $ dpkg -l
    and you get a nice list of packages installed.
    You don’t even have to run it as root!

  • pirat9

    correct and give a simple outout. in other command you have some variable to sort and to list how many packages by size … . or other varibale,

  • Zinovsky

    There are many commands to list packages in Linux ,For example the command bellow will give us the list of all the currently installed packages:
    [code]dpkg �get-selections[/code]

    All has one goal is to list the packages but every command list the package different way, for example the second command above use the dpkg-query tool and give you the list of installed packages by size from smaller size to bigger size.

  • Foo

    Almost working. This command:
    [code]$sudo dpkg-query -Wf ‘${Installed-Size}t${Package}n’ | sort -n[/code]
    Also shows uninstalled packages that haven’t been purged.

  • Crash Test Dummy

    anonymous got it right.

    for newbies and crash test dummies like myself,

    CTRL-ALT-T to open a terminal

    dpkg -l -> newfile.txt
    more newfile.txt

    where is any filename you like

  • Aa

    The second one needs backslashes: $sudo  dpkg-query -Wf ‘${Installed-Size}t${Package}n’ | sort -n

  • Pp

    Thank you, Aa. The second one as you ammended it works just fine. Without your backslashes it produced clutter. The 1st one doesn’t work 4 me.

  • Me

    I just found this and hoped it (the first method) would allow me to recover the package list from a borked (failed dist-upgrade) oneiric box. Unfortunately the first method (the potentially useful one) fails to operate on a Precise live DVD session. :-(
    (no output whatsoever)

    Naturally the second (useless to me for this purpose) method works perfectly.

    Any idea what’s gone wrong?

    PS. Yes, I changed ” /var/lib/dpkg/status” to the correct path for the mounted host “/” …I also ran it unmolested and it failed to produce the package list of the live session. Your second method did successfully produce the latter live DVD package list but is obviously incapable of doing what I need.

  • Mathew W Gathoka

    Thanks alot.

  • Vincent Beers

    Okay, now how can I get a subselection of packages from this, like finding all installed packages containing for example “gnome”?