Showing posts with label Dpkg. Show all posts
Showing posts with label Dpkg. Show all posts

Monday, 6 May 2013

How to check what we have Installed in Debuian/Ubuntu OS


To check what have install by listing all using dpkg is easy.
dpkg -l
To check whether a package is install also easy.
dpkg -l | grep apache
The command above is some how redundant, because dpkg support wild characters, doing this instead
dpkg -l "apache*"
By doing this, it will also list the package that not install but available in dpkg cache, to install them you can simply apt-get. To indicate the packages installed it shows “ii” and not install shows “un”.

Shell Script File for Checking Package Installed or not Or If not then Install Package - For Ubuntu OS

Dpkg: check that unix package is installed. Bash script: install package if not present

dpkg -s can be used.
Example: is vlc installed?
> dpkg -s vlc|grep installed
Here is some logic in bash script, like installing package if it is not there:
1
2
3
4
5
6
problem=$(dpkg -s vlc|grep installed)
 echo Checking for libxul: $problem
 if [ "" == "$problem" ]; then
      echo "No libxul. Setting up libxul"
      sudo apt-get --force-yes --yes install vlc
 fi