list installed packages on debian

I just want to share this simple command to show you how to list out all installed packages on a system.  It is often useful when you need to compare two system, or easily check to see if you installed a package already.

dpkg –get-selections

server:/var/log/openvpn# dpkg –get-selections
acpi-support-base                               install
acpid                                           install
adduser                                         install
apache2                                         install
apache2-mpm-prefork                             install
apache2-utils                                   install
apache2.2-common                                install
apt                                             install
… and losts more

This also works on Debian like operating systems like Ubuntu.  Below is a example from my Debian desktop.

user@server:~$ dpkg –get-selections|grep xserver
x11-xserver-utils                               install
xserver-common                                  install
xserver-xorg                                    install
xserver-xorg-core                               install
xserver-xorg-input-all                          install
xserver-xorg-input-evdev                        install
xserver-xorg-input-mouse                        install
xserver-xorg-input-synaptics                    install
xserver-xorg-input-vmmouse                      install
xserver-xorg-input-wacom                        install
xserver-xorg-video-all                          install
xserver-xorg-video-apm                          install
xserver-xorg-video-ark                          install
xserver-xorg-video-ati                          install
xserver-xorg-video-chips                        install
xserver-xorg-video-cirrus                       install
xserver-xorg-video-fbdev                        install
xserver-xorg-video-geode                        install
xserver-xorg-video-i128                         install
xserver-xorg-video-i740                         install
xserver-xorg-video-intel                        install
xserver-xorg-video-mach64                       install
xserver-xorg-video-mga                          install
xserver-xorg-video-neomagic                     install
xserver-xorg-video-nv                           install
xserver-xorg-video-openchrome                   install
xserver-xorg-video-r128                         install
xserver-xorg-video-radeon                       install
xserver-xorg-video-rendition                    install
xserver-xorg-video-s3                           install
xserver-xorg-video-s3virge                      install
xserver-xorg-video-savage                       install
xserver-xorg-video-siliconmotion                install
xserver-xorg-video-sis                          install
xserver-xorg-video-sisusb                       install
xserver-xorg-video-tdfx                         install
xserver-xorg-video-trident                      install
xserver-xorg-video-tseng                        install
xserver-xorg-video-v4l                          install
xserver-xorg-video-vesa                         install
xserver-xorg-video-vmware                       install
xserver-xorg-video-voodoo                       install