由於 GNU/Linux 的發行版本很多,多數又有繼承演化的關係,要辨認出每個版本不是一件容易的事。以下是一些簡單的辨別方法,越前面的越精確,但不見得都適用,若該方法行不通,請退而求其次,試試下一個方法。
執行 lsb_release -a
這是最精確的方法,以下是一些輸出範例:
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 8.10
Release: 8.10
Codename: intrepid
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 4.0 (etch)
Release: 4.0
Codename: etch
LSB Version: :core-3.1-ia32:core-3.1-noarch:graphics-3.1-ia32:graphics-3.1-noarch執行 ls /etc/*release 再執行 cat /etc/*release
Distributor ID: CentOS
Description: CentOS release 5.2 (Final)
Release: 5.2
Codename: Final
有許多發行版本的資訊都寫在 /etc/*release 的檔案之中,例如:
- /etc/lsb-release (Ubuntu)
- /etc/SuSE-release (SuSE)
- /etc/redhat-release (RedHat, CentOS)
- /etc/mandrake-release (Mandrake)
- /etc/distro-release (AsteriskNOW)
有另一些發行版本的資訊是寫在 /etc/*version 的檔案之中,例如:
- /etc/debian_version (Debian, Ubuntu)
- /etc/slackware-version (Slackware)
嚴格說來,這不是正確的方法,因為此檔案是用來儲存一些要秀給使用者登入時看的訊息。但很多 distro 都會在這個檔案寫上自己的發行名稱,所以也是不錯的參考資料。例如:
- Ubuntu 8.10 \n \l
- Ubuntu 8.04.2 \n \l
- Debian GNU/Linux 4.0 \n \l
- CentOS release 5.2 (Final) Kernel \r on an \m
此方法的訊息更不明確,但也不失為一個判斷的依據。例如:
- Ubuntu 8.10 => Linux version 2.6.27-11-generic (buildd@yellow) (gcc version 4.3.2 (Ubuntu 4.3.2-1ubuntu11) ) #1 SMP Wed Apr 1 20:53:41 UTC 2009
- Ubuntu 8.04.2 => Linux version 2.6.24-23-server (buildd@vernadsky) (gcc version 4.2.3 (Ubuntu 4.2.3-2ubuntu7)) #1 SMP Mon Jan 26 00:55:21 UTC 2009
- Debian 4.0 => Linux version 2.6.22-3-vserver-amd64 (Debian 2.6.22-6) (maks@debian.org) (gcc version 4.1.3 20071019 (prerelease) (Debian 4.1.2-17)) #1 SMP Sun Nov 4 18:41:00 UTC 2007
- CentOS 5.2 => Linux version 2.6.18-92.el5 (mockbuild@builder16.centos.org) (gcc version 4.1.2 20071124 (Red Hat 4.1.2-42)) #1 SMP Tue Jun 10 18:49:47 EDT 2008