You can look at the apt log under /var/log/apt/ and the dpkg log under /var/log/

and you can get the list of the installed packages with just a command:

dpkg -l | grep '^ii '

To list all installed packages,

dpkg -l |awk '/^[hi]i/{print $2}' > 1.txt
aptitude search -F '%p' '~i' > 1.txt
dpkg --get-selections > 1.txt


dpkg-query (instead of dpkg –get-selections, which lists some packages that are not installed) as follows:

dpkg-query -W -f='${PackageSpec} ${Status}\n' | grep installed |  sort -u | cut -f1 -d \ > installed-pkgs


$ dpkg -l | grep ^ii | sed 's_  _\t_g' | cut -f 2 > installed-pkgs

Create a backup of what packages are currently installed:

dpkg --get-selections > list.txt

Then (on another system) restore installations from that list:

dpkg --clear-selections
sudo dpkg --set-selections < list.txt

To get rid of stale packages

sudo apt-get autoremove

To get installed like at backup time (i.e. to install packages set by dpkg --set-selections)

sudo apt-get dselect-upgrade

To get just the packages which were expressly installed (not just installed as dependencies), you can run

aptitude search '~i!~M'

871down voteaccepted

To get a list of packages installed locally do this in your terminal:

dpkg --get-selections | grep -v deinstall

(The -v tag “inverts” grep to return non-matching lines)

To get a list of a specific package installed:

dpkg --get-selections | grep postgres

To save that list to a text file called packages on your desktop do this in your terminal:

dpkg --get-selections | grep -v deinstall > ~/Desktop/packages

Alternatively, simply use

dpkg -l

And in case you wondered, apt can do this, too.

(Note – old Ubuntu Syntax, does not work on Ubuntu 12.04 and above)

apt --installed list

sudo apt-get purge --auto-remove packagename

it will purge required packages along with dependencies that are installed with that packages. --auto-remove option work similar to sudo apt-get autoremove




Posted in ITMS

Leave a Reply

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