During troubleshooting, or even when setting up an unfamiliar server, it’s quite a common question to ask what software / packages is actually installed on the server you’re working on. For example, I got asked to install Joomla on a server I’ve never touched before. I needed to check which of the prerequisite software packages were already installed on the system
The simplest way of doing this in my opinion is to use the dpkg –l command. This lists all the installed packages. In combination with the usual linux terminal tricks it should give all you need. For example you may run the command
dpkg – l > installed_packages.txt
And then browse the resulting text file. Or if you’re looking for something in particular (like apache2 in my case) you can use the command in combination with grep like so:
dpkg –l | grep apache
which give an output similar to:
root@ubuntu:/var/www# dpkg -l | grep apache
ii apache2 2.2.11-2ubuntu2.7 Apache HTTP Server metapackage
ii apache2-mpm-prefork 2.2.11-2ubuntu2.7 Apache HTTP Server – traditional non-
ii apache2-utils 2.2.11-2ubuntu2.7 utility programs for webservers
ii apache2.2-common 2.2.11-2ubuntu2.7 Apache HTTP Server common files
ii libapache2-mod-php5 5.2.6.dfsg.1-3ubuntu4.6 server-side, HTML-embedded scripting
As you can see, the output lists the package name, the version, and a short text description of the package