pyてよn日記

一寸先は闇が人生

Linux:ディストリビューションの種類,バージョン確認

 Linux ディストリビューションの種類,バージョン確認をするコマンドをまとめた.

/etc 配下のファイルを確認する:ワンライナー

 Linux システムの /etc 配下にディストリビューション,バージョン等に関する情報が記載されたファイルが存在する.表示するには以下のワンライナーを実行すればよい.

$ grep -H "" /etc/*version ; grep -H "" /etc/*release

 やっていることは単純で,以下 2 つのコマンドを行っているだけ.

  • $ cat /etc/*version
  • $ cat /etc/*release

 Debian 環境を例に示す.

$ grep -H "" /etc/*version ; grep -H "" /etc/*release
# /etc/debian_version:10.2
# grep: /etc/subversion: Is a directory
# /etc/os-release:PRETTY_NAME="Debian GNU/Linux 10 (buster)"
# /etc/os-release:NAME="Debian GNU/Linux"
# /etc/os-release:VERSION_ID="10"
# /etc/os-release:VERSION="10 (buster)"
# /etc/os-release:VERSION_CODENAME=buster
# /etc/os-release:ID=debian
# /etc/os-release:HOME_URL="https://www.debian.org/"
# /etc/os-release:SUPPORT_URL="https://www.debian.org/support"
# /etc/os-release:BUG_REPORT_URL="https://bugs.debian.org/"

/etc 配下のファイルを確認する:ファイルごと

 /etc 配下には,上記に示した以外にもディストリビューションの情報を確認できるファイルが存在する.前述のファイルも含め,個別に見ていく.

  • 共通:/etc/os-release/etc/issue/proc/version を確認
$ 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/"

$ cat /etc/issue
# Debian GNU/Linux 10 \n \l

$ cat /proc/version
#Linux version 4.9.184-linuxkit (root@a8c33e955a82) (gcc version 8.3.0 (Alpine 8.3.0) ) #1 SMP Tue Jul 2 22:58:16 UTC 2019

参考