Apt-cache: How to list all installed packages with version number?

listed in answer

Apt-cache: How to list all installed packages with version number?
0 votes, 0.00 avg. rating (0% score)

ANSWER:

To list the names of each installed package, type as a superuser :

dpkg --get-selections

You will get an output like this :

accountsservice              install
aclinstall                   install
acpi-supportinstall          install
acpidinstall                 install
...

To remove the unecessary “install” character string, you can use sed :

dpkg --get-selections | sed 's:install$::'

And if yout want to save it to a file called InstalledPackages, you type this :

dpkg --get-selections | sed 's:install$::' > InstalledPackages

by Rémi G. from http://superuser.com/questions/418077