How to get a list of installed software packages? [duplicate]
Ubuntu 14.04 and above
The apt
tool on Ubuntu 14.04 and above makes this very easy.
apt list --installed
Older Versions
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
(you don't need to run any of these commands as the superuser, so no sudo
or any other variants necessary here)
To get just the packages which were expressly installed (not just installed as dependencies), you can run
aptitude search '~i!~M'
This will also include a brief description, which you may want. If not, also add the option -F '%p'
, as mentioned by karthick87.
Yet another option seems to be to copy the file /var/lib/apt/extended_states
, which is a text file database in this format:
Package: grub-common
Architecture: amd64
Auto-Installed: 0
Package: linux-headers-2.6.35-22-generic
Architecture: amd64
Auto-Installed: 1
Auto-Installed: 0
indicates that the package was expressly installed and is not just a dependency.
To list all packages intentionally installed (not as dependencies) by apt commands, run the following :
(zcat $(ls -tr /var/log/apt/history.log*.gz); cat /var/log/apt/history.log) 2>/dev/null |
egrep '^(Start-Date:|Commandline:)' |
grep -v aptdaemon |
egrep '^Commandline:'
This provides a reverse time based view, with older commands listed first:
Commandline: apt-get install k3b
Commandline: apt-get install jhead
...
Installation data also showing synaptic usage, but without details (the same with installation date) :
(zcat $(ls -tr /var/log/apt/history.log*.gz); cat /var/log/apt/history.log) 2>/dev/null |
egrep '^(Start-Date:|Commandline:)' |
grep -v aptdaemon |
egrep -B1 '^Commandline:'
providing the following:
Start-Date: 2012-09-23 14:02:14
Commandline: apt-get install gparted
Start-Date: 2012-09-23 15:02:51
Commandline: apt-get install sysstat
...
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
apt-mark showmanual
man pages state:
will print a list of manually installed packages
So, it should just give a list of explicitly installed packages (though this includes packages that were part of the default initial install) without all of the dependencies included due to these packages being installed.
To output the result into a text file:
apt-mark showmanual > list-manually-installed.txt