shell判断Linux发行版的命令
发布于 分类 Linux
1天前 有1个用户阅读过
Get_Dist_Name()
{
if grep -Eqi"CentOS" /etc/issue || grep -Eq"CentOS" /etc/*-release; then
DISTRO='CentOS'
PM='yum'
elif grep -Eqi"Red Hat Enterprise Linux Server" /etc/issue || grep -Eq"Red Hat Enterprise Linux Server" /etc/*-release; then
DISTRO='RHEL'
PM='yum'
elif grep -Eqi"Aliyun" /etc/issue || grep -Eq"Aliyun" /etc/*-release; then
DISTRO='Aliyun'
PM='yum'
elif grep -Eqi"Fedora" /etc/issue || grep -Eq"Fedora" /etc/*-release; then
DISTRO='Fedora'
PM='yum'
elif grep -Eqi"Debian" /etc/issue || grep -Eq"Debian" /etc/*-release; then
DISTRO='Debian'
PM='apt'
elif grep -Eqi"Ubuntu" /etc/issue || grep -Eq"Ubuntu" /etc/*-release; then
DISTRO='Ubuntu'
PM='apt'
elif grep -Eqi"Raspbian" /etc/issue || grep -Eq"Raspbian" /etc/*-release; then
DISTRO='Raspbian'
PM='apt'
else
DISTRO='unknow'
fi
}
总结要点有:1. cat /etc/issue
2. cat /etc/*-release
3. 哪些发行版使用yum 那些发行版使用apt
-- The End --