これは、なにをしたくて書いたもの?
Linux OSのバージョン情報などを見る時の方法をまとめておこうかな、と。
特にディストリビューションによって変わらない方法で見る場合は?ということであれば、/etc/os-release
を見るのが
良さそうです。
確認方法
/etc/os-release
には、OSの識別情報が含まれています。
os-release - Operating system identification at Linux.org
その他、ディストリビューションに寄った確認方法だと、Ubuntu LinuxやDebianだとlsb_release
コマンド、
CentOSなどだと/etc/redhat-release
ファイルを使うなどがあります。
あと、/proc/version
やuname
を使うのも良いでしょう。
いくつかのOSで試してみましょう。
Ubuntu Linux 20.04 LTS
/etc/os-release
。
NAME="Ubuntu" VERSION="20.04.2 LTS (Focal Fossa)" ID=ubuntu ID_LIKE=debian PRETTY_NAME="Ubuntu 20.04.2 LTS" VERSION_ID="20.04" HOME_URL="https://www.ubuntu.com/" SUPPORT_URL="https://help.ubuntu.com/" BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/" PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy" VERSION_CODENAME=focal UBUNTU_CODENAME=focal
lsb_release
と/etc/lsb-release
。
$ lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 20.04.2 LTS Release: 20.04 Codename: focal $ cat /etc/lsb-release DISTRIB_ID=Ubuntu DISTRIB_RELEASE=20.04 DISTRIB_CODENAME=focal DISTRIB_DESCRIPTION="Ubuntu 20.04.2 LTS"
uname
。
$ uname -srvmpio Linux 5.4.0-77-generic #86-Ubuntu SMP Thu Jun 17 02:35:03 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
/proc/version
。
$ cat /proc/version Linux version 5.4.0-77-generic (buildd@lgw01-amd64-028) (gcc version 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04)) #86-Ubuntu SMP Thu Jun 17 02:35:03 UTC 2021
Debian 10 Buster
/etc/os-release
。
$ cat /etc/os-release PRETTY_NAME="Debian GNU/Linux 10 (buster)" NAME="Debian GNU/Linux" VERSION_ID="10" VERSION="10 (buster)" VERSION_CODENAME=buster ID=debian HOME_URL="https://www.debian.org/" SUPPORT_URL="https://www.debian.org/support" BUG_REPORT_URL="https://bugs.debian.org/"
lsb_release
。
$ lsb_release -a No LSB modules are available. Distributor ID: Debian Description: Debian GNU/Linux 10 (buster) Release: 10 Codename: buster
uname
。
$ uname -srvmpio Linux 4.19.0-16-amd64 #1 SMP Debian 4.19.181-1 (2021-03-19) x86_64 unknown unknown GNU/Linux
/proc/version
。
$ cat /proc/version Linux version 4.19.0-16-amd64 (debian-kernel@lists.debian.org) (gcc version 8.3.0 (Debian 8.3.0-6)) #1 SMP Debian 4.19.181-1 (2021-03-19)
CentOS 8
/etc/os-release
。
$ cat /etc/os-release NAME="CentOS Linux" VERSION="8" ID="centos" ID_LIKE="rhel fedora" VERSION_ID="8" PLATFORM_ID="platform:el8" PRETTY_NAME="CentOS Linux 8" ANSI_COLOR="0;31" CPE_NAME="cpe:/o:centos:centos:8" HOME_URL="https://centos.org/" BUG_REPORT_URL="https://bugs.centos.org/" CENTOS_MANTISBT_PROJECT="CentOS-8" CENTOS_MANTISBT_PROJECT_VERSION="8"
/etc/redhat-release
。
$ cat /etc/redhat-release CentOS Linux release 8.4.2105
uname
。
$ uname -mrspvio Linux 4.18.0-305.7.1.el8_4.x86_64 #1 SMP Tue Jun 29 21:55:12 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
/proc/version
。
$ cat /proc/version Linux version 4.18.0-305.7.1.el8_4.x86_64 (mockbuild@kbuilder.bsys.centos.org) (gcc version 8.4.1 20200928 (Red Hat 8.4.1-1) (GCC)) #1 SMP Tue Jun 29 21:55:12 UTC 2021
Alpine Linux 3.12
/etc/os-release
。
NAME="Alpine Linux" ID=alpine VERSION_ID=3.12.7 PRETTY_NAME="Alpine Linux v3.12" HOME_URL="https://alpinelinux.org/" BUG_REPORT_URL="https://bugs.alpinelinux.org/"
/etc/alpine-release
。
$ cat /etc/alpine-release 3.12.7
uname
。
$ uname -srvmpio Linux 5.4.111-0-virt #1-Alpine SMP Mon, 12 Apr 2021 16:11:34 UTC x86_64 unknown unknown Linux
/proc/version
。
$ cat /proc/version Linux version 5.4.111-0-virt (buildozer@build-3-12-x86_64) (gcc version 9.3.0 (Alpine 9.3.0)) #1-Alpine SMP Mon, 12 Apr 2021 16:11:34 UTC