Skip to content

Instantly share code, notes, and snippets.

@alanljj
Created April 3, 2019 03:16
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alanljj/1433da4a373191051fe6c44d7d3c78b5 to your computer and use it in GitHub Desktop.
Save alanljj/1433da4a373191051fe6c44d7d3c78b5 to your computer and use it in GitHub Desktop.
get linux version shell
#!/bin/bash
Get_Dist_Name()
{
if grep -Eqii "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
echo $DISTRO;
}
if Get_Dist_Name = "Raspbian"; then
echo "-------- This is $DISTRO OS !!! --------"
else
echo "!!!!!!!! Never heard about this OS !!! !!!!!!!! --------"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment