重庆SEO, 关注并探索SEO与WEB技术。针对用户体验,提供白帽SEO以及PHP网站建设以及运营服务。

shell判断Linux发行版的命令

发布于 作者 [重庆SEO]

Markdown版本

下面的shell脚本函数引用自 lnmp1.2-full/include/main.sh
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
分类:Linux

Tags: 命令, 判断, 发行,

本文标题: shell判断Linux发行版的命令

本文地址: https://seonoco.com/blog/shell-to-determine-the-linux-issue

版权说明: 本站遵循 CC BY-NC-SA 4.0 协议, 未表明转载信息均为原创或整理,转载或引用请注明出处,以便溯本求源。

补充说明: 本文在本站发布于2015-12-18,文中部分内容可能存在过时或不正确,请知晓!如果可以请留言告知。

本文是否有所帮助?
点赞
说一说
打赏