Linux checks the kernel and distribution information of the current system
Currently onlyCentOS
andUbuntu
System testing, other systems will be slightly different.
1. Pass the command: less /proc/version (kernel and distribution information)
Centos 8:
Linux version 4.18.0-147.5.1.el8_1.x86_64 (mockbuild@) (gcc version 8.3.1 20190507 (Red Hat 8.3.1-4) (GCC)) #1 SMP Wed Feb 5 02:00:39 UTC 2020
Ubuntu 18.04.1:
Linux version 4.15.0-65-generic (buildd@lgw01-amd64-006) (gcc version 7.4.0 (Ubuntu 7.4.0-1ubuntu1~18.04.1)) #74-Ubuntu SMP Tue Sep 17 17:06:04 UTC 2019
Note:
- Different systems may display differently, but they can generally be distinguished.
-
Linux version
Refers to the kernel version. -
CentOS
Words:el8_1
,Number 8
RepresentsCentOS 8
-
Ubuntu
It is the following18.04.1
, means yesUbuntu 18.04
2. Pass the command: uname -a (kernel and distribution information)
- CentOS 8:
Linux iZ2ze90lblkm0mixai571vZ 4.18.0-147.5.1.el8_1.x86_64 #1 SMP Wed Feb 5 02:00:39 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
It is determined by el8.
- Ubuntu:
Linux blog 4.15.0-65-generic #74-Ubuntu SMP Tue Sep 17 17:06:04 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
Use Ubuntu to determine it is an Ubuntu system.
3. Pass the command: lsb_release -a (only view release information)
- CentOS:
Distributor ID: CentOS Description: CentOS Linux release 8.1.1911 (Core) Release: 8.1.1911 Codename: Core
- Ubuntu:
Distributor ID: Ubuntu Description: Ubuntu 18.04.3 LTS Release: 18.04 Codename: bionic
4. Use the less /etc/*-release command (view release information)
passless /etc/*-release
Can match multiple files and enter them in command mode:n
Browse the next file,:p
Browse the previous file, and you can see more detailed information in this way, or you can view a certain file separately:
-
CentOS
: General viewredhat-release
、os-release
、lsb-release
、system-release
. Different versions of these files may not necessarily be available. -
Ubuntu
: General viewos-release
、lsb-release
. Different versions of these files may not necessarily be available.
Generally speaking, you can get the desired kernel information and distribution information through the above methods.
Summarize
The above is personal experience. I hope you can give you a reference and I hope you can support me more.