linux查看软件是否安装

1 temp=`dpkg -l | grep "openssl"
2 if [ -n "$temp" ];then
3     echo "openssl已经安装"
4 elif [ -z "$temp" ];then
5     echo "openssl未安装"
6 fi

1. rpm包安装的

    rpm -qa | grep "软件包名称“

2.deb包安装的

    dpkg -l | grep "软件包名称"

3.yum安装的

    yum list installed | grep "软件包名称"

4.如果是以源码包自己编译安装的,例如:tar.gz或者tar.bz2,这个只能检测可执行文件是否存在了。

如果是以root用户安装的通常是在/sbin:/usr/bin目录下

 

######################################

temp=`/bin/ls *.conf 2>/dev/null`
for c in $temp; do
if [ -f $c ];then
    echo $c
fi
done

循环显示以.conf结尾的文件名

2>/dev/null 错误重定向到/dev/null

#######################################

posted @ 2012-12-26 23:28  快传万家  阅读(3148)  评论(0编辑  收藏  举报