2-2-2 lsb_release システムの基本情報の確認 Linux

estis2016/06/14 (火) 12:51 に投稿

ディストリビューション情報を表示する。

 lsb_release -irs

 
コマンドがない場合

 cat /etc/*release

[root@localhost ~]# man lsb_release
FSG(1)                                FSG                               FSG(1)

NAME
       FSG - manual page for FSG lsb_release v2.0

SYNOPSIS
       lsb_release [OPTION]...

DESCRIPTION
       FSG lsb_release v2.0 prints certain LSB (Linux Standard Base) and Distribution information.

       With no OPTION specified defaults to -v.

OPTIONS
       -v, --version

              Display the version of the LSB specification against which the distribution is compliant.

       -i, --id

              Display the string id of the distributor.

       -d, --description

              Display the single line text description of the distribution.

       -r, --release

              Display the release number of the distribution.

       -c, --codename

              Display the codename according to the distribution release.

       -a, --all

              Display all of the above information.

       -s, --short

              Use short output format for information requested by other options (or version if none).

       -h, --help

              Display this message.

FILES
       If  the  installation is LSB compliant, the "/etc/lsb-release" file should contain the LSB_VERSION field.  The value of the field should be a colon separated list of supported module versions indicating the LSB specification modules to which the
       installation is compliant. If the installation is not compliant, the above field should not be present.

       Optional fields are DISTRIB_ID, DISTRIB_RELEASE, DISTRIB_CODENAME, DISTRIB_DESCRIPTION and can be used to override information which is parsed from the "/etc/distrib-release" file.

       If the "/etc/lsb-release.d" directory exists, it is searched for filenames which are taken as additional module-version strings to add to LSB_VERSION.

       The "/etc/distrib-release" file contains a description line which is parsed to get information (especially on currently non-LSB compliant systems).

       The required line style is:
       "Distributor release x.x (Codename)"

       Where Distributor can be a couple of words, but then concatenated (i.e. Linux Foo BarLinux Linux -> FooBarLinux),
       x.x starts with a digit followed by any non-blank characters, Codename will also be concatenated (blanks cleanup only).

       release may not be used as a keyword in DISTRIB_DESCRIPTION if you don’t want to override "/etc/distrib-release" data.

       Notice: To support the Debian distributions’ lack of information (see "/etc/debian_version" file) some have been directly added into the lsb_release script.

EXAMPLES
       If the "/etc/lsb-release" file contains:

       LSB_VERSION="core-2.0-ia64:core-2.0-noarch"
       DISTRIB_DESCRIPTION="I enjoy using my distrib"

       and the "/etc/lsb-release.d" directory contains:
	   
       graphics-2.0-ia64    graphics-2.0-noarch

       and the "/etc/foobar-release" file contains:

       My Linux Distrib release 1.0RC4 (TryIt)

       Then the results of various options will be:

       $ ./lsb_release --all
       LSB Version:    core-2.0-ia64:core-2.0-noarch:graphics-2.0-ia64:graphics-2.0-noarch
       Distributor ID: MyDistrib
       Description:    I enjoy using my distrib
       Release:        1.0RC4
       Codename:       TryIt

       $ ./lsb_release -a -s
       1.0 MyDistrib "I enjoy using my distrib" 1.0RC4 TryIt

       If the "/etc/lsb-release" file is absent (indicating this is not an LSB compliant distribution), the result will be:

       $ ./lsb_release -a
       LSB Version:    n/a
       Distributor ID: MyDistrib
       Description:    My Linux Distrib release 1.0RC4 (TryIt)
       Release:        1.0RC4
       Codename:       TryIt

REPORTING BUGS
       Report bugs at http://bugs.linuxbase.org.  Please include a complete, self contained example that will allow the bug to be reproduced, and say which version of lsb_release you are using.

COPYRIGHT
       Copyright © 2000, 2002, 2004 Free Standards Group, Inc.
       This is free software; see the source for copying conditions.  There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

       Originally written by Dominique MASSONIE.

FSG lsb_release v2.0             February 2013                          FSG(1)

実行例

[root@localhost ~]# lsb_release
LSB Version:	:base-4.0-ia32:base-4.0-noarch:core-4.0-ia32:core-4.0-noarch

[root@localhost ~]# lsb_release --version; lsb_release -v
LSB Version:	:base-4.0-ia32:base-4.0-noarch:core-4.0-ia32:core-4.0-noarch
LSB Version:	:base-4.0-ia32:base-4.0-noarch:core-4.0-ia32:core-4.0-noarch

[root@localhost ~]# lsb_release --id; lsb_release -i
Distributor ID:	CentOS
Distributor ID:	CentOS

[root@localhost ~]# lsb_release --description; lsb_release -d
Description:	CentOS release 6.8 (Final)
Description:	CentOS release 6.8 (Final)

[root@localhost ~]# lsb_release --release; lsb_release -r
Release:	6.8
Release:	6.8

[root@localhost ~]# lsb_release --codename; lsb_release -c
Codename:	Final
Codename:	Final

[root@localhost ~]# lsb_release --all; lsb_release -a
LSB Version:	:base-4.0-ia32:base-4.0-noarch:core-4.0-ia32:core-4.0-noarch
Distributor ID:	CentOS
Description:	CentOS release 6.8 (Final)
Release:	6.8
Codename:	Final
LSB Version:	:base-4.0-ia32:base-4.0-noarch:core-4.0-ia32:core-4.0-noarch
Distributor ID:	CentOS
Description:	CentOS release 6.8 (Final)
Release:	6.8
Codename:	Final

[root@localhost ~]# lsb_release --short; lsb_release -s
:base-4.0-ia32:base-4.0-noarch:core-4.0-ia32:core-4.0-noarch
:base-4.0-ia32:base-4.0-noarch:core-4.0-ia32:core-4.0-noarch
[root@localhost ~]# lsb_release --version --short; lsb_release -vs
:base-4.0-ia32:base-4.0-noarch:core-4.0-ia32:core-4.0-noarch
:base-4.0-ia32:base-4.0-noarch:core-4.0-ia32:core-4.0-noarch
[root@localhost ~]# lsb_release --id --short; lsb_release -is
CentOS
CentOS
[root@localhost ~]# lsb_release --description --short; lsb_release -ds
"CentOS release 6.8 (Final)"
"CentOS release 6.8 (Final)"
[root@localhost ~]# lsb_release --release --short; lsb_release -rs
6.8
6.8
[root@localhost ~]# lsb_release --codename --short; lsb_release -cs
Final
Final
[root@localhost ~]# lsb_release --all --short; lsb_release -as
:base-4.0-ia32:base-4.0-noarch:core-4.0-ia32:core-4.0-noarch CentOS "CentOS release 6.8 (Final)" 6.8 Final
:base-4.0-ia32:base-4.0-noarch:core-4.0-ia32:core-4.0-noarch CentOS "CentOS release 6.8 (Final)" 6.8 Final

[root@localhost ~]# lsb_release --help; lsb_release -h
FSG lsb_release v2.0 prints certain LSB (Linux Standard Base) and
Distribution information.

Usage: lsb_release [OPTION]...
With no OPTION specified defaults to -v.

Options:
  -v, --version
    Display the version of the LSB specification against which the distribution is compliant.
  -i, --id
    Display the string id of the distributor.
  -d, --description
    Display the single line text description of the distribution.
  -r, --release
    Display the release number of the distribution.
  -c, --codename
    Display the codename according to the distribution release.
  -a, --all
    Display all of the above information.
  -s, --short
    Use short output format for information requested by other options (or version if none).
  -h, --help
    Display this message.
FSG lsb_release v2.0 prints certain LSB (Linux Standard Base) and
Distribution information.

Usage: lsb_release [OPTION]...
With no OPTION specified defaults to -v.

Options:
  -v, --version
    Display the version of the LSB specification against which the distribution is compliant.
  -i, --id
    Display the string id of the distributor.
  -d, --description
    Display the single line text description of the distribution.
  -r, --release
    Display the release number of the distribution.
  -c, --codename
    Display the codename according to the distribution release.
  -a, --all
    Display all of the above information.
  -s, --short
    Use short output format for information requested by other options (or version if none).
  -h, --help
    Display this message.

ディストリビューションIDとリリース番号を表示する。
short オプションを使うと、1行にまとめて表示される(場合もある)。
この情報で十分。

[root@localhost ~]# lsb_release -ir
Distributor ID:	CentOS
Release:	6.8

[root@localhost ~]# lsb_release -irs
CentOS 6.8

root@debian:~# lsb_release -irs
Debian
8.5

バージョン表示オプションがあっても、他のオプション結果も表示される。
このバージョンは、コマンドのバージョンではない。

[root@localhost ~]# lsb_release -iv
LSB Version:	:base-4.0-ia32:base-4.0-noarch:core-4.0-ia32:core-4.0-noarch
Distributor ID:	CentOS

バージョン確認

[root@localhost ~]# rpm -q --info redhat-lsb-core
Name        : redhat-lsb-core              Relocations: (not relocatable)
Version     : 4.0                               Vendor: CentOS
Release     : 7.el6.centos                  Build Date: 2013年02月22日 20時23分47秒
Install Date: 2015年11月30日 22時32分31秒      Build Host: c6b9.bsys.dev.centos.org
Group       : System Environment/Base       Source RPM: redhat-lsb-4.0-7.el6.centos.src.rpm
Size        : 22561                            License: GPL
Signature   : RSA/SHA1, 2013年02月24日 02時52分11秒, Key ID 0946fca2c105b9de
Packager    : CentOS BuildSystem 
URL         : http://www.linuxfoundation.org/collaborate/workgroups/lsb
Summary     : LSB base libraries support for CentOS
Description :
The Linux Standard Base (LSB) Core Libraries Specifications define components
that are required to be present on an LSB conforming system.

ユーザー実行可能

[estis@localhost ~]$ lsb_release -as
:base-4.0-ia32:base-4.0-noarch:core-4.0-ia32:core-4.0-noarch CentOS "CentOS release 6.8 (Final)" 6.8 Final

redhat-lsb-core をインストールとすると、インストールされる。

[root@localhost ~]# yum provides lsb_release
読み込んだプラグイン:fastestmirror
Loading mirror speeds from cached hostfile
 * base: ftp.iij.ad.jp
 * extras: ftp.iij.ad.jp
 * updates: ftp.iij.ad.jp
redhat-lsb-core-4.1-27.el7.centos.1.i686 : LSB Core module support
リポジトリー        : base
一致          :
ファイル名    : /usr/bin/lsb_release



redhat-lsb-core-4.1-27.el7.centos.1.x86_64 : LSB Core module support
リポジトリー        : base
一致          :
ファイル名    : /usr/bin/lsb_release

Debian 8.5 での実行例

root@debian:~# lsb_release -irs
Debian
8.5

root@debian:~# lsb_release -a
No LSB modules are available.
Distributor ID:	Debian
Description:	Debian GNU/Linux 8.5 (jessie)
Release:	8.5
Codename:	jessie

root@debian:~# apt-cache showpkg lsb-release
Package: lsb-release
Versions: 
4.1+Debian13+nmu1 (/var/lib/apt/lists/ftp.jp.debian.org_debian_dists_jessie_main_binary-amd64_Packages) (/var/lib/dpkg/status)
 Description Language: 
                 File: /var/lib/apt/lists/ftp.jp.debian.org_debian_dists_jessie_main_binary-amd64_Packages
                  MD5: 65ec3e346c054b77b914b6a1d4e5fb15
 Description Language: en
                 File: /var/lib/apt/lists/ftp.jp.debian.org_debian_dists_jessie_main_i18n_Translation-en
                  MD5: 65ec3e346c054b77b914b6a1d4e5fb15
 Description Language: ja
                 File: /var/lib/apt/lists/ftp.jp.debian.org_debian_dists_jessie_main_i18n_Translation-ja
                  MD5: 65ec3e346c054b77b914b6a1d4e5fb15


Reverse Depends: 
  whatmaps,lsb-release
  unattended-upgrades,lsb-release
  ubuntu-dev-tools,lsb-release
  python3-software-properties,lsb-release
  python-software-properties,lsb-release
  simple-cdd,lsb-release
  salt-common,lsb-release
  ruby-specinfra,lsb-release
  rhn-client-tools,lsb-release
  python3-apt,lsb-release
  python-apt,lsb-release
  python3-kerberos,lsb-release
  puppet-common,lsb-release
  postgresql-server-dev-all,lsb-release
  postgresql-client-common,lsb-release
  plainbox-provider-resource-generic,lsb-release
  piuparts,lsb-release
  pastebinit,lsb-release
  mumble,lsb-release
  lxsession,lsb-release
  ltsp-server,lsb-release
  ltsp-client-core,lsb-release
  lsb-core,lsb-release 4.1+Debian13+nmu1
  ladvd,lsb-release
  isenkram-cli,lsb-release
  icinga2-common,lsb-release
  hobbit-plugins,lsb-release
  debirf,lsb-release
  debian-edu-config,lsb-release
  command-not-found,lsb-release
  byobu,lsb-release
  aptoncd,lsb-release
  apt-forktracer,lsb-release 3.2-21
  apt-dater-host,lsb-release
  apt-clone,lsb-release
Dependencies: 
4.1+Debian13+nmu1 - python (2 2.7) python (3 2.8) lsb (0 (null)) apt (0 (null)) 
Provides: 
4.1+Debian13+nmu1 - 
Reverse Provides: 

root@debian:~# lsb_release -h
Usage: lsb_release [options]

Options:
  -h, --help         show this help message and exit
  -v, --version      show LSB modules this system supports
  -i, --id           show distributor ID
  -d, --description  show description of this distribution
  -r, --release      show release number of this distribution
  -c, --codename     show code name of this distribution
  -a, --all          show all of the above information
  -s, --short        show requested information in short format

Ubuntu 16.04 での実行例

estis@ubuntu:~$ lsb_release -irs
Ubuntu
16.04

estis@ubuntu:~$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 16.04 LTS
Release:	16.04
Codename:	denial

estis@ubuntu:~$ apt-cache showpkg lsb-release
Package: lsb-release
Versions: 
9.20160110 (/var/lib/apt/lists/jp.archive.ubuntu.com_ubuntu_dists_xenial_main_binary-amd64_Packages) (/var/lib/apt/lists/jp.archive.ubuntu.com_ubuntu_dists_xenial_main_binary-i386_Packages) (/var/lib/dpkg/status)
 Description Language: 
                 File: /var/lib/apt/lists/jp.archive.ubuntu.com_ubuntu_dists_xenial_main_binary-amd64_Packages
                  MD5: 65ec3e346c054b77b914b6a1d4e5fb15
 Description Language: ja
                 File: /var/lib/apt/lists/jp.archive.ubuntu.com_ubuntu_dists_xenial_main_i18n_Translation-ja
                  MD5: 65ec3e346c054b77b914b6a1d4e5fb15
 Description Language: en
                 File: /var/lib/apt/lists/jp.archive.ubuntu.com_ubuntu_dists_xenial_main_i18n_Translation-en
                  MD5: 65ec3e346c054b77b914b6a1d4e5fb15


Reverse Depends: 
  apt-forktracer,lsb-release 3.2-21
  python-commandnotfound,lsb-release
  ubiquity,lsb-release
  python3-distupgrade,lsb-release
  python3-commandnotfound,lsb-release
  python3-apport,lsb-release
  python-apport,lsb-release
  plymouth-theme-ubuntu-text,lsb-release
  livecd-rootfs,lsb-release
  firefox,lsb-release
  xe-guest-utilities,lsb-release
  whatmaps,lsb-release
  ubuntu-dev-tools,lsb-release
  ubuntu-core-libs,lsb-release
  sugar-session,lsb-release
  spl-dkms,lsb-release
  software-center,lsb-release
  simple-cdd,lsb-release
  salt-common,lsb-release
  rhn-client-tools,lsb-release
  python3-kerberos,lsb-release
  python-software-properties,lsb-release
  python-commandnotfound,lsb-release
  puppet-module-asciiduck-sssd,lsb-release
  puppet-common,lsb-release
  postgresql-server-dev-all,lsb-release
  piuparts,lsb-release
  opendrim-lmp-softwareupdate,lsb-release
  mythbuntu-common,lsb-release
  mumble,lsb-release
  lxsession-logout,lsb-release
  lxsession,lsb-release
  ltsp-server,lsb-release
  ltsp-client-core,lsb-release
  libertine-tools,lsb-release
  isenkram-cli,lsb-release
  installation-report-generator,lsb-release
  icinga2-common,lsb-release
  hobbit-plugins,lsb-release
  dell-recovery,lsb-release
  debirf,lsb-release
  cobbler,lsb-release
  bootchart,lsb-release
  auto-upgrade-tester,lsb-release
  aptoncd,lsb-release
  apt-clone,lsb-release
  apt-dater-host,lsb-release
  update-manager-core,lsb-release
  unity-scope-home,lsb-release
  unattended-upgrades,lsb-release
  ubuntu-minimal,lsb-release
  ubuntu-defaults-builder,lsb-release
  ubiquity,lsb-release
  snapd,lsb-release
  python3-update-manager,lsb-release
  python3-software-properties,lsb-release
  python3-distupgrade,lsb-release
  python3-commandnotfound,lsb-release
  python3-apt,lsb-release
  python3-apport,lsb-release
  python-apt,lsb-release
  python-apport,lsb-release
  postgresql-client-common,lsb-release
  plymouth-theme-ubuntu-text,lsb-release
  plainbox-provider-resource-generic,lsb-release
  nvidia-prime,lsb-release
  livecd-rootfs,lsb-release
  landscape-common,lsb-release
  firefox,lsb-release
  byobu,lsb-release
Dependencies: 
9.20160110 - python3:any (2 3.4~) distro-info-data (0 (null)) apt (0 (null)) lsb (0 (null)) 
Provides: 
9.20160110 - lsb-release:i386 (= 9.20160110) 
Reverse Provides:

estis@ubuntu:~$ lsb_release -h
Usage: lsb_release [options]

Options:
  -h, --help         show this help message and exit
  -v, --version      show LSB modules this system supports
  -i, --id           show distributor ID
  -d, --description  show description of this distribution
  -r, --release      show release number of this distribution
  -c, --codename     show code name of this distribution
  -a, --all          show all of the above information
  -s, --short        show requested information in short format



lsb_release コマンドが使用できない場合は、/etc ディレクトリにあるファイルを確認する。
/etc/issue は、他の目的のため編集される可能性がある事に注意。

RedHat系
CentOS では、/etc/redhat-release が、/etc/centos-release のソフトリンクになっている。
[root@localhost ~]#  cat /etc/redhat-release 
CentOS release 6.8 (Final)

[root@localhost ~]#  cat /etc/issue
CentOS release 6.8 (Final)
Kernel \r on an \m

[estis@localhost ~]$ cat /etc/*release
CentOS release 6.8 (Final)
LSB_VERSION=base-4.0-ia32:base-4.0-noarch:core-4.0-ia32:core-4.0-noarch
CentOS release 6.8 (Final)
CentOS release 6.8 (Final)

[estis@localhost ~]$ ls -l /etc/*release
-rw-r--r--. 1 root root 27  5月 19 04:46 2016 /etc/centos-release
-rw-r--r--. 1 root root 72 11月 30 22:32 2015 /etc/lsb-release
lrwxrwxrwx. 1 root root 14  6月 14 13:08 2016 /etc/redhat-release -> centos-release
lrwxrwxrwx. 1 root root 14  6月 14 13:08 2016 /etc/system-release -> centos-release

[root@localhost ~]# cat /etc/redhat-release CentOS Linux release 7.2.1511 (Core) [root@localhost ~]# cat /etc/issue \S Kernel \r on an \m [root@localhost ~]# cat /etc/*release CentOS Linux release 7.2.1511 (Core) NAME="CentOS Linux" VERSION="7 (Core)" ID="centos" ID_LIKE="rhel fedora" VERSION_ID="7" PRETTY_NAME="CentOS Linux 7 (Core)" ANSI_COLOR="0;31" CPE_NAME="cpe:/o:centos:centos:7" HOME_URL="https://www.centos.org/" BUG_REPORT_URL="https://bugs.centos.org/" CENTOS_MANTISBT_PROJECT="CentOS-7" CENTOS_MANTISBT_PROJECT_VERSION="7" REDHAT_SUPPORT_PRODUCT="centos" REDHAT_SUPPORT_PRODUCT_VERSION="7" CentOS Linux release 7.2.1511 (Core) CentOS Linux release 7.2.1511 (Core) [root@localhost ~]# ls -l /etc/*release -rw-r--r--. 1 root root 38 12月 9 2015 /etc/centos-release -rw-r--r--. 1 root root 393 12月 9 2015 /etc/os-release lrwxrwxrwx. 1 root root 14 6月 14 14:42 /etc/redhat-release -> centos-release lrwxrwxrwx. 1 root root 14 6月 14 14:42 /etc/system-release -> centos-release

Debian系

root@debian:~# cat /etc/debian_version 
8.5

root@debian:~# cat /etc/issue
Debian GNU/Linux 8 \n \l

root@debian:~# cat /etc/*release 
PRETTY_NAME="Debian GNU/Linux 8 (jessie)"
NAME="Debian GNU/Linux"
VERSION_ID="8"
VERSION="8 (jessie)"
ID=debian
HOME_URL="http://www.debian.org/"
SUPPORT_URL="http://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

root@debian:~# ls -l /etc/*release 
lrwxrwxrwx 1 root root 21  5月 30 13:18 /etc/os-release -> ../usr/lib/os-release

Ubuntu

estis@ubuntu:~$ cat /etc/os-release 
NAME="Ubuntu"
VERSION="16.04 LTS (Xenial Xerus)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 16.04 LTS"
VERSION_ID="16.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
UBUNTU_CODENAME=xenial

estis@ubuntu:~$ ls -l /etc/os-release 
lrwxrwxrwx 1 root root 21  6月 14 17:33 /etc/os-release -> ../usr/lib/os-release

estis@ubuntu:~$ cat /etc/issue
Ubuntu 16.04 LTS \n \l


estis@ubuntu:~$ cat /etc/*release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.04
DISTRIB_CODENAME=xenial
DISTRIB_DESCRIPTION="Ubuntu 16.04 LTS"
NAME="Ubuntu"
VERSION="16.04 LTS (Xenial Xerus)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 16.04 LTS"
VERSION_ID="16.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
UBUNTU_CODENAME=xenial

estis@ubuntu:~$ ls -l /etc/*release
-rw-r--r-- 1 root root 103  4月 13 05:12 /etc/lsb-release
lrwxrwxrwx 1 root root  21  6月 14 17:33 /etc/os-release -> ../usr/lib/os-release