Check what is installed on Debian / Ubuntu version ?
For linux Version :
uname -a >> 2.6.5-1.358 #1 Sat May 8 09:04:50 EDT 2004 i686 i686 i386 GNU/Linux
For the version Debian you can use :
cat /etc/debian_version
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”.
To know more, sometimes we wanna know what files is installed with the package. But with this query, you need to put the exact package name.
dpkg -L apache2
To list more simple result for script manipulation? You can check out dpkg-query, it support -l and -L and more options. For example, -W will list only the package name and the version for installed packages.
dpkg-query -W "apache*"
To be more specific, check out the dpkg manual at -f, you can specified what should only output. A simple example, where I just want the package name.
dpkg-query -W -f='${Package}n' "apache*"