2019年10月2日 星期三

[Linux 常見問題] How to Check CentOS Version

Source From Here
Question
Knowing the exact kernel version or OS version is sometimes necessary while troubleshooting an issue or providing information to the support team. This post will assist you to determine the OS and kernel version of the CentOS or RHEL system you are running.

There are 2 major things to check when it comes to finding the version of any Linux system. They are
1. Check the OS Update Level
2. Check the running kernel version

1. Check the CentOS/RHEL OS Update Level
The 4 files shown below provides the update version of the CentOS/Redhat OS.
* /etc/centos-release
* /etc/os-release
* /etc/redhat-release
* /etc/system-release

The content of each of the above files from a CentOS 7.4 system is shown below.
# cat /etc/redhat-release
CentOS Linux release 7.4.1708 (Core)

# cat /etc/centos-release
CentOS Linux release 7.4.1708 (Core)
# cat /etc/os-release
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"


# cat /etc/system-release
CentOS Linux release 7.4.1708 (Core)

The above 4 files are provided by the package centos-release.

# rpm -ql centos-release | grep release$
/etc/centos-release
/etc/os-release
/etc/redhat-release
/etc/system-release

You can find out release information by checking the versioning reported the rpm database. For example:
# rpm -qf /etc/redhat-release
centos-release-7-4.1708.el7.centos.x86_64

2. Check the Running Kernel version
You can find out which CentOS kernel version and architecture you are using with the uname command. Do “man uname” for details of the uname command. Examples:
# uname -s -r
Linux 3.10.0-693.21.1.el7.x86_64

# uname -a
Linux geeklab 3.10.0-693.21.1.el7.x86_64 #1 SMP Wed Mar 7 19:03:37 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

Check kernel compile time (uname -v) and compare with known value:
# uname -v
#1 SMP Wed Mar 7 19:03:37 UTC 2018

You can also Verify the kernel package using the rpm command. The command would produce an output only if there is any issue with the installed kernel.
# rpm -q --verify kernel-3.10.0-693.21.1.el7.x86_64

Checking CentOS 7 version
Apart from all the above commands, you can also use the command “hostnamectl” to find OS version information in CentOS 7 systems. For example:
# hostnamectl
Static hostname: geeklab
Icon name: computer-vm
Chassis: vm
Machine ID: f9afeb75a5a382dce8269887a67fbf58
Boot ID: 668b5c55c6b9438b9356438d8beceec6
Virtualization: xen
Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0-693.21.1.el7.x86_64
Architecture: x86-64

Checking the LSB version
Another way to check the centOS version is using the “lsb_release” command. The lsb_release command is provided by the package “redhat-lsb”. This package may not be present by default on the system and you may need to install it first.
# yum install redhat-lsb

Examples of lsb_release command:
# lsb_release -d
Description: CentOS Linux release 7.4.1708 (Core)

# lsb_release -r
Release: 7.4.1708

# lsb_release -a
LSB Version: :core-4.1-amd64:core-4.1-noarch:cxx-4.1-amd64:cxx-4.1-noarch:desktop-4.1-amd64:desktop-4.1-noarch:languages-4.1-amd64:languages-4.1-noarch:printing-4.1-amd64:printing-4.1-noarch
Distributor ID: CentOS
Description: CentOS Linux release 7.4.1708 (Core)
Release: 7.4.1708
Codename: Core


沒有留言:

張貼留言

[Git 常見問題] error: The following untracked working tree files would be overwritten by merge

  Source From  Here 方案1: // x -----删除忽略文件已经对 git 来说不识别的文件 // d -----删除未被添加到 git 的路径中的文件 // f -----强制运行 #   git clean -d -fx 方案2: 今天在服务器上  gi...