How to check if a package is installed ubuntu

Before installing a package on your ubuntu, its a best practice to check if that package installed already. Many of the popular packages are pre installed with all the linux distribution these days. Use “dpkg” tool to check if a package is installed ubuntu server. This command will be helpful n verifying the installed package, checking the package version, architecture, description, etc. This command will work with all Ubuntu servers like Ubuntu 12.04, Ubuntu 14.04, Ubuntu 14.10, etc.

How to check if a package is installed ubuntu

In this example, we are going to check if the Clam antivirus is installed on my Ubuntu server. Clam is one of the best antivirus for all the linux distributions including Ubuntu.

Command usage ( The -l switch stands for List )

dpkg -l <packageName>

Example

sreekanth@DigitPAGE:~$ sudo dpkg -l clamav

Sample output that got for me

||/ Name              Version                                    Architecture             Description

+++-================================-=====================-=====================-=====================================================================

ii  clamav             0.98.5+dfsg-0ubuntu0.       amd64                         anti-virus utility for Unix – command-line interface

If you don’t know the exact package name

If you dont know the exact package name, so search it with the some part of the package name. The command will do the rest..

dpkg -l | grep <packageName>

example, “clamav” is the exact package name. Simply search it with the partial name “clam”. The command will list all the packages that’s name contains the word “clam”.

sreekanth@DigitPAGE:~$ sudo dpkg -l | grep clam

List all the packages installed on Ubuntu machine

dpkg -l