{"id":2735,"date":"2016-06-06T14:44:34","date_gmt":"2016-06-06T06:44:34","guid":{"rendered":"http:\/\/ixyzero.com\/blog\/?p=2735"},"modified":"2016-06-06T14:44:34","modified_gmt":"2016-06-06T06:44:34","slug":"%e5%a6%82%e4%bd%95%e5%88%a4%e6%96%adlinux%e7%b3%bb%e7%bb%9f%e7%9a%84%e5%85%b7%e4%bd%93%e5%8f%91%e8%a1%8c%e7%89%88%e6%9c%ac%e4%bf%a1%e6%81%af","status":"publish","type":"post","link":"https:\/\/ixyzero.com\/blog\/archives\/2735.html","title":{"rendered":"\u5982\u4f55\u5224\u65adLinux\u7cfb\u7edf\u7684\u5177\u4f53\u53d1\u884c\u7248\u672c\u4fe1\u606f"},"content":{"rendered":"<p>=Start=<\/p>\n<h5>\u7f18\u7531\uff1a<\/h5>\n<p>\u4e0d\u540c\u7684Linux\u53d1\u884c\u7248\u6709\u4e0d\u540c\u7684\u300c\u5305\u7ba1\u7406\u5de5\u5177\u300d\uff0c\u6240\u4ee5\u6709\u65f6\u540c\u4e00\u4e2a\u8f6f\u4ef6\u5bf9\u5e94\u7684\u5b89\u88c5\u5305\u540d\u79f0\u548c\u5b89\u88c5\u547d\u4ee4\u4e5f\u90fd\u4e0d\u4e00\u6837\uff08\u751a\u81f3\u540c\u4e00\u53d1\u884c\u7248\u7684\u4e0d\u540c\u7248\u672c\u4e4b\u95f4\u4e5f\u4f1a\u6709\u6240\u4e0d\u540c\uff09\uff0c\u5982\u679c\u9700\u8981\u5199\u7c7b\u4f3c\u4e8e LNMP \u7b49\u517c\u5bb9\u5404Linux\u7cfb\u7edf\u7684\u4e00\u952e\u5b89\u88c5\u5de5\u5177\u65f6\uff0c\u662f\u9700\u8981\u63d0\u524d\u5224\u65adLinux\u7cfb\u7edf\u7684\u5177\u4f53\u53d1\u884c\u7248\u4fe1\u606f\u7684\uff0c\u7136\u540e\u6839\u636e\u5bf9\u5e94\u7684\u7248\u672c\u4fe1\u606f\u8fdb\u884c\u64cd\u4f5c\u3002\u8fd9\u91cc\u6211\u6839\u636e\u4ee5\u5f80\u7684\u4e00\u4e9b\u7ecf\u9a8c\u8bb0\u5f55\u4e00\u4e0b\u5e38\u89c1Linux\u7cfb\u7edf\u53d1\u884c\u7248\u7684\u5224\u65ad\u65b9\u6cd5\uff0c\u4f5c\u4e3a\u5907\u5fd8\u548c\u53c2\u8003\u3002<\/p>\n<h5>\u6b63\u6587\uff1a<\/h5>\n<p>\u51c6\u786e\u5224\u65adLinux\u7cfb\u7edf\u7684\u53d1\u884c\u7248\u9700\u8981\u5bf9LFS\u548c\u5404Linux\u53d1\u884c\u7248\u8db3\u591f\u719f\u6089\u624d\u884c\uff0c\u4e0b\u9762\u662f\u6211\u78b0\u5230\u7684\u4e00\u4e9b\u5e38\u7528\u7684Linux\u53d1\u884c\u7248\u53ca\u5bf9\u5e94\u5305\u7ba1\u7406\u5de5\u5177\uff1a<\/p>\n<ul>\n<li>Fedora \/ RedHat \/ CentOS<br \/>\n$ yum\/rpm<\/li>\n<li>Gentoo<br \/>\n$ emerge<\/li>\n<li>Debian \/ Ubuntu<br \/>\n$ apt-get\/dpkg<\/li>\n<li>Arch<br \/>\n$ pacman<\/li>\n<\/ul>\n<p>\u6839\u636e\u81ea\u5df1\u4e4b\u524d\u7684\u4e00\u4e9b\u7ecf\u9a8c\uff0c<span style=\"color: #ff0000;\"><strong>\u4e00\u822c\u60c5\u51b5\u4e0b\u53ef\u4ee5\u6839\u636e\u5982\u4e0b3\u4e2a\u6587\u4ef6\u6765\u5224\u65adLinux\u7cfb\u7edf\u7684\u5177\u4f53\u53d1\u884c\u7248\u672c\u4fe1\u606f<\/strong><\/span>\uff1a<\/p>\n<ul>\n<li>\/etc\/*release<\/li>\n<li>\/etc\/*version<\/li>\n<li>\/etc\/*issue*<\/li>\n<\/ul>\n<h6>\u4e00\u4e2a\u7b80\u5355\u7684Linux\u7cfb\u7edf\u53d1\u884c\u7248\u672c\u68c0\u6d4b\u811a\u672c\uff1a<\/h6>\n<pre class=\"lang:default decode:true\">function check_os_type()\n{\n    local line\n\n    line=`head -n 1 \/etc\/issue`\n    if echo $line|grep \"[Cc]ent[Oo][Ss]\" &gt;\/dev\/null; then\n        br_os_type=1\n    elif echo $line|grep \"[Rr]ed.Hat.Enterprise\" &gt;\/dev\/null; then\n        br_os_type=2\n    elif echo $line|grep \"[Uu]buntu\" &gt;\/dev\/null; then\n        br_os_type=3\n    elif echo $line|grep \"[Dd]ebian\" &gt;\/dev\/null; then\n        br_os_type=4\n    elif echo $line|grep \"[Ff]edora\" &gt;\/dev\/null; then\n        br_os_type=5\n    else\n        echo -e \"unknown os type - $line is not supported.\"\n        exit 0\n    fi\n\n    echo -e \"target os type - $line\"\n    echo $br_os_type\n}<\/pre>\n<h6>\u4e00\u4e2a\u8f83\u4e3a\u901a\u7528\u7684Linux\u7cfb\u7edf\u7248\u672c\u4fe1\u606f\u68c0\u6d4b\u811a\u672c\uff1a<\/h6>\n<pre class=\"lang:default decode:true \">#!\/bin\/bash\n# Detects which OS and if it is Linux then it will detect which Linux Distribution.\n# https:\/\/www.novell.com\/coolsolutions\/feature\/11251.html\n\nOS=`uname -s`\nREV=`uname -r`\nMACH=`uname -m`\n\nif [ \"${OS}\" = \"SunOS\" ] ; then\n    OS=Solaris\n    ARCH=`uname -p`\n    OSSTR=\"${OS} ${REV}(${ARCH} `uname -v`)\"\nelif [ \"${OS}\" = \"AIX\" ] ; then\n    OSSTR=\"${OS} `oslevel` (`oslevel -r`)\"\nelif [ \"${OS}\" = \"Linux\" ] ; then\n    KERNEL=`uname -r`\n    if [ -f \/etc\/redhat-release ] ; then\n        DIST='RedHat'\n        PSUEDONAME=`cat \/etc\/redhat-release | sed s\/.*\\(\/\/ | sed s\/\\)\/\/`\n        REV=`cat \/etc\/redhat-release | sed s\/.*release\\ \/\/ | sed s\/\\ .*\/\/`\n    elif [ -f \/etc\/SUSE-release ] ; then\n        DIST=`cat \/etc\/SUSE-release | tr \"\\n\" ' '| sed s\/VERSION.*\/\/`\n        REV=`cat \/etc\/SUSE-release | tr \"\\n\" ' ' | sed s\/.*=\\ \/\/`\n    elif [ -f \/etc\/mandrake-release ] ; then\n        DIST='Mandrake'\n        PSUEDONAME=`cat \/etc\/mandrake-release | sed s\/.*\\(\/\/ | sed s\/\\)\/\/`\n        REV=`cat \/etc\/mandrake-release | sed s\/.*release\\ \/\/ | sed s\/\\ .*\/\/`\n    elif [ -f \/etc\/debian_version ] ; then\n        DIST=\"Debian `cat \/etc\/debian_version`\"\n        REV=\"\"\n    fi\n\n    if [ -f \/etc\/UnitedLinux-release ] ; then\n        DIST=\"${DIST}[`cat \/etc\/UnitedLinux-release | tr \"\\n\" ' ' | sed s\/VERSION.*\/\/`]\"\n    fi\n\n    OSSTR=\"${OS} ${DIST} ${REV}(${PSUEDONAME} ${KERNEL} ${MACH})\"\nfi\n\necho ${OSSTR}<\/pre>\n<h6>\u53c2\u8003\u94fe\u63a5\uff1a<\/h6>\n<ul>\n<li><a href=\"http:\/\/unix.stackexchange.com\/questions\/35183\/how-do-i-identify-which-linux-distro-is-running\">http:\/\/unix.stackexchange.com\/questions\/35183\/how-do-i-identify-which-linux-distro-is-running<\/a><\/li>\n<li><a href=\"http:\/\/unix.stackexchange.com\/questions\/6345\/how-can-i-get-distribution-name-and-version-number-in-a-simple-shell-script\">http:\/\/unix.stackexchange.com\/questions\/6345\/how-can-i-get-distribution-name-and-version-number-in-a-simple-shell-script<\/a><\/li>\n<li><a href=\"http:\/\/www.unix.com\/shell-programming-and-scripting\/27932-how-know-linux-distribution-i-am-using.html\">http:\/\/www.unix.com\/shell-programming-and-scripting\/27932-how-know-linux-distribution-i-am-using.html<\/a><\/li>\n<li><a href=\"https:\/\/www.novell.com\/coolsolutions\/feature\/11251.html\">https:\/\/www.novell.com\/coolsolutions\/feature\/11251.html<\/a><\/li>\n<li><a href=\"http:\/\/superuser.com\/questions\/80251\/how-to-know-which-linux-distribution-im-using\">http:\/\/superuser.com\/questions\/80251\/how-to-know-which-linux-distribution-im-using<\/a><\/li>\n<li><a href=\"http:\/\/serverfault.com\/questions\/3331\/how-do-i-find-out-what-version-of-linux-is-running\/3334#3334\">http:\/\/serverfault.com\/questions\/3331\/how-do-i-find-out-what-version-of-linux-is-running\/3334#3334<\/a><\/li>\n<li><a href=\"http:\/\/superuser.com\/questions\/618660\/how-can-i-determine-the-distro-of-linux-that-is-running-on-a-remote-server\/618661\">http:\/\/superuser.com\/questions\/618660\/how-can-i-determine-the-distro-of-linux-that-is-running-on-a-remote-server\/618661<\/a><\/li>\n<li><a href=\"http:\/\/www.cyberciti.biz\/faq\/command-to-show-linux-version\/\">http:\/\/www.cyberciti.biz\/faq\/command-to-show-linux-version\/<\/a><\/li>\n<li><a href=\"http:\/\/askubuntu.com\/questions\/459402\/how-to-know-if-the-running-platform-is-ubuntu-or-centos-with-help-of-a-bash-scri\">http:\/\/askubuntu.com\/questions\/459402\/how-to-know-if-the-running-platform-is-ubuntu-or-centos-with-help-of-a-bash-scri<\/a><\/li>\n<li><a href=\"http:\/\/unix.stackexchange.com\/questions\/92199\/how-can-i-reliably-get-the-operating-systems-name\/92218#92218\">http:\/\/unix.stackexchange.com\/questions\/92199\/how-can-i-reliably-get-the-operating-systems-name\/92218#92218<\/a><\/li>\n<\/ul>\n<p>=END=<\/p>\n","protected":false},"excerpt":{"rendered":"<p>=Start= \u7f18\u7531\uff1a \u4e0d\u540c\u7684Linux\u53d1\u884c\u7248\u6709\u4e0d\u540c\u7684\u300c\u5305\u7ba1\u7406\u5de5\u5177\u300d\uff0c\u6240\u4ee5\u6709\u65f6\u540c\u4e00\u4e2a\u8f6f\u4ef6\u5bf9\u5e94\u7684\u5b89\u88c5\u5305\u540d\u79f0\u548c\u5b89\u88c5 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23,11,7],"tags":[621,622,30],"class_list":["post-2735","post","type-post","status-publish","format-standard","hentry","category-knowledgebase-2","category-linux","category-programing","tag-etcissue","tag-etcredhat-release","tag-linux"],"views":3487,"_links":{"self":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/2735","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/comments?post=2735"}],"version-history":[{"count":0,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/2735\/revisions"}],"wp:attachment":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/media?parent=2735"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/categories?post=2735"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/tags?post=2735"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}