how to look for packets to install or already installed

This is my first article since I am also using Debian (now just upgraded to Squeeze) 😀

However, since I am working only by ssh, I found out that the following two commands are very very useful to know…

Take in account that all the commands are run as root, so if you are not, you may need the ‘sudo’ in front..

If you want to search through the repository for tomcat, run an update:

apt-get update

Then you can be sure that the list you are going to look through is the most recent and therefore:

apt-cache search tomcat

This will print out all the result matching the string ‘tomcat’

Instead, if you wanna look through all the *installed* packet, then type:

dpkg --get-selections | grep tomcat

Among the result, packages with a corresponding ‘deinstall’ are those packages that have been removed without the ‘–purge’ option…

If you want to purge them all, just type:

aptitude purge $(dpkg --get-selections | grep deinstall | sed s/deinstall//)

Ps: a special thanks to Alessia for giving me a reason to continue to publish on this space 😀