RHEL サーバーのマイナー バージョンは、/etc/redhat-release ファイルによって定義され、redhat-release-server パッケージに属します。 lsb_release スクリプトは、「cat /etc/redhat-release」と同じ出力を与える /etc/redhat-release を指します。 Linux Standard Base (LSB) は基本的に、複数のディストリビューションがサインアップする標準です。 Filesystem Hierarchy Standard (FHS) および Linux システムのその他のさまざまなコンポーネントを指定します。
OS のバージョンを取得するために Ubuntu が lsb_release を使用していることに気付いたかもしれません。 CentOS でも同じことができますが、最初に lsb_release をインストールする必要があります:
# yum install redhat-lsb-core
これで、OS 情報を取得するために Ubuntu が使用するのと同じコマンドを実行できます。
$ lsb_release -s -d "CentOS Linux release 7.5.1804 (Core) "
デフォルトで何もインストールしなくても、Debian でも同じことができます:
$ lsb_release -s -d Debian GNU/Linux 9.5 (stretch)
lsb_release コマンドの例
1. LSB 分布情報を取得するには:
# lsb_release
2. すべての LSB 分布情報を取得するには:
# lsb_release -a # lsb_release --all
3. ディストリビュータの文字列 ID を表示するには:
# lsb_release -i # lsb_release --id
4. 1 行のテキスト分布を表示するには:
# lsb_release -d # lsb_release --description
5. ディストリビューションのリリース番号を表示するには:
# lsb_release -r # lsb_release --release
6. 配布リリースに従ってコードネームを表示するには:
# lsb_release -c # lsb_release --codename
7. 要求された情報に短い出力形式を使用するには:
# lsb_release -s # lsb_release --short
8. ヘルプを表示するには:
# lsb_release -h # lsb_release --help