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
[...]
root@anneke:~#

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
root@anneke:~# 

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
/.
/usr
/usr/share
/usr/share/php5
/usr/share/php5/mysql
/usr/share/php5/mysql/mysqli.ini
/usr/share/php5/mysql/mysql.ini
/usr/share/php5/mysql/pdo_mysql.ini
/usr/share/doc
/usr/lib
/usr/lib/php5
/usr/lib/php5/20100525+lfs
/usr/lib/php5/20100525+lfs/mysql.so
/usr/lib/php5/20100525+lfs/mysqli.so
/usr/lib/php5/20100525+lfs/pdo_mysql.so
/usr/share/doc/php5-mysql
root@anneke:~# 


Hope this helps :) Cheers!