1. 查看内核版本(kernel version)信息:
[arthur@localhost genome]$ uname -a
Linux localhost.localdomain 4.18.0-240.22.1.el8_3.x86_64 #1 SMP Thu Apr 8 19:01:30 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
2. 查看发行版本信息(distribution information)
不同的系统发行版本需要使用不同的命令。
#centos 默认不支持 Linux Standard Base,需要安装
[arthur@localhost genome]$ lsb_release -a
bash: lsb_release: command not found...
Install package 'redhat-lsb-core' to provide command 'lsb_release'? [N/y] N
[arthur@localhost genome]$ ll /etc/lsb-release
ls: cannot access '/etc/lsb-release': No such file or directory
#/etc/issue 文件包含信息或者系统识别信息,这些信息在登入提示之前会进行输出
#`r` : insert the release number of the OS
#`m` : insert the architecture identifier of the machine
[arthur@localhost genome]$ cat /etc/issue.net
\S
Kernel \r on an \m
#对于 centos 或者 redhat linux发行版本,可以使用如下命令:
[arthur@localhost genome]$ cat /etc/redhat-release
CentOS Linux release 8.3.2011
#同样,可以采用如下方式:
[arthur@localhost genome]$ 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"
#或者:
[arthur@localhost genome]$ grep '^VERSION' /etc/os-release
VERSION="8"
VERSION_ID="8"
[arthur@localhost genome]$ egrep '^(VERSION|NAME)=' /etc/os-release
NAME="CentOS Linux"
VERSION="8"
#或者:
[arthur@localhost genome]$ cat /proc/version
Linux version 4.18.0-240.22.1.el8_3.x86_64 (mockbuild@kbuilder.bsys.centos.org) (gcc version 8.3.1 20191121 (Red Hat 8.3.1-5) (GCC)) #1 SMP Thu Apr 8 19:01:30 UTC 2021
reference :
[1] man7.org/linux/man-pages/man8/agetty.8.html
[2] how to check os version in Linux command line.cyberciti.