Small knowledge, big challenge! This article is participating in the creation activity of “Essential Tips for Programmers”.

Uname Viewing system information (Linux kernel version)

The uname (full: Unix name) command is used to display system information and the Linux kernel version.

You can view the Linux kernel version by running the uname -r command.

Parameters of the uname command are described as follows:

  • -aor--allDisplay all information.
  • -mor--machineDisplay schema types.
  • -nor--nodenameThe host name displayed on the network.
  • -ror--releaseThe Linux kernel version is displayed.
  • -sor--sysnameThe operating system name is displayed.
  • -vThe operating system version is displayed.
  • --helpShow help.
  • --versionThe version information is displayed.

As follows:

[root@VM_0_15_centos ~]# uname
Linux
[root@VM_0_15_centos ~]# uname -r3.10.0-957.21.3. El7. X86_64 / root @ VM_0_15_centos ~# uname -aLinux VM_0_15_centos 3.10.0-957.21.3. El7. X86_64#1 SMP Tue Jun 18 16:35:19 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
Copy the code

Other:

[root@VM_0_15_centos ~]# uname -m
x86_64
[root@VM_0_15_centos ~]# uname -n
VM_0_15_centos
[root@VM_0_15_centos ~]# uname -v
#1 SMP Tue Jun 18 16:35:19 UTC 2019
[root@VM_0_15_centos ~]# uname -s
Linux
Copy the code

SMP: Symmetrical multi-processing or Symmetric multi-processor is a common system architecture mode for servers.

The previous 3.10.0 in the distribution is the Linux kernel version used by RHEL/Centos7.

The /etc/redhat-release file is used to view the distribution

# cat /etc/redhat-release
CentOS Linux release 7.3.1611 (Core)
Copy the code

The /proc/version file displays the detailed version

# cat /proc/version
Linux version 3.10.0-957.21.3.el7.x86_64 ([email protected]) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC) ) #1 SMP Tue Jun 18 16:35:19 UTC 2019
Copy the code

The lsb_release command displays the system version information

Lsb_release command

The lsb_release command displays LSB (Linux Standard Base) information about a particular Linux distribution, Includes version number, Release Codename, and Distributor ID.

# lsb_release -aLSB Version: : Core-4.1-AMD64: Core-4.1-noarch Distributor ID: CentOS Description: CentOS Linux release 7.3.1611 (Core) release: 7.3.1611 Codename: CoreCopy the code

This command is applicable to all Linux distributions, including Redhat, SUSE, and Debian, when LSB Core is installed.

Install the LSB Core

Lsb_release is part of the LSB Core package. Default does not have to be installed on the system.

The following is an introduction to the installation of LSB Core on several different systems:

  • RHEL/Centos
sudo yum update && sudo yum install redhat-lsb-core
Copy the code
  • RHEL8/Centos8/Fedora
sudo dnf update && sudo dnf install redhat-lsb-core
Copy the code
  • Ubuntu, Debian
sudo apt-get update && sudo apt-get install lsb-core
Copy the code
  • OpenSUSE
sudo zypper update && sudo zypper install lsb-core
Copy the code
  • Arch
pacman -Syu lsb-release
Copy the code

other

The commands above, especially uname, list all distributions and kernel versions, as well as machine information.

In addition, there may be less-used, or more subtle, ways to obtain version or schema bit information, as described below.

  • Getconf LONG_BIT or getconf WORD_BIT
# getconf LONG_BIT
64
Copy the code

Long ints represent the number of bits in the system.

  • /bin/ls File Information (file /bin/ls)
# file /bin/ls
/bin/ls: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), forGNU/Linux 2.6.32, BuildID [sha1] = 3 d705971a4c4544545cb78fd890d27bf792af6d4, strippedCopy the code

ELF stands for “Executable and Linkable Format” and can execute the Linkable file Format. Currently, common Linux, Android Executable files, shared libraries (. So), object files (. O) and Core files (vomiting Core) all use this Format.

reference

  • Linux uname command
  • Linux lsb_release command
  • How to Query the centos Check the system kernel version, system version, 32-bit or 64-bit