Archive

Posts Tagged ‘shell auto uninstall packages’

rpm(centos),apt-get(debian) auto detect and uninstall packages(bash shell)

August 27th, 2010 No comments

Here goes the thinking:First,use rpm -qa or apt-cache policy to find the name of the package(s) to remove.Then,use rpm -e or apt-get remove to uninstall the packages.
Detect the os type by bash shell:http://www.doxer.org/linux-shell-centos-debian-ostype/
#centos begin
rpm -qa|grep httpd #under centos it's httpd,debian apache
if [ $? = '0' ];then
aa="`rpm -qa|grep httpd`" #get the full-name of the package
rpm -e $aa
fi

#debian begin
apt-cache policy apache2|grep "Installed: 2." -q
if [ #? = '0'];then
apt-get remove apache2
fi