Sunday, November 4, 2012

Show the List of Installed Packages on Ubuntu or Debian

The command we need to use to know the list of Installed Packages on Ubutu and/or Debis is dpkg –get-selections, which will give us a list of all the currently installed packages.

root@anneke:~# dpkg --get-selections
adduser                                         install
alsa-base                                       install
alsa-utils                                      install
apache2                                         install
apache2-mpm-prefork                             install
apache2-utils                                   install
apache2.2-common                                install
apt                                             install
apt-utils                                       install

The full list can be quite long, so it’s much easier to filter through grep to get results for the exact package you need. For instance, I wanted to see which mysql packages I had already installed through apt-get:

root@anneke:~# dpkg --get-selections | grep mysql
libdbd-mysql-perl install
libmysqlclient18:i386 install
mysql-client-5.5 install
mysql-client-core-5.5 install
mysql-common install
mysql-server install
mysql-server-5.5 install
mysql-server-core-5.5 install
php5-mysql install

For extra credit, you can find the locations of the files within a package from the list by using the dpkg -L command, such as:

root@anneke:~# dpkg -L php5-mysql

Hope this helps :) Cheers!