uname 命令的输出就可以获取这些信息,但这些信息都是什么,它告诉了你什么?
在这篇文章中,我们将仔细看看 uname 命令的输出,以及一些其他命令和文件提供的版本描述。
使用 uname
每当你在linux系统终端窗口中发出uname -a命令时,就会显示很多信息。 事实上,每一块显示的信息都会告诉你一些关于系统的不同信息。
uname -a命令=uname -snmrvpio
Linux parallels 3.10.0-862.11.6.el7.x86_64 #1 SMP Tue Aug 14 21:49:04 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
通过help命令可以看到详细的说明
uname --help
Usage: uname [OPTION]...
Print certain system information. With no OPTION, same as -s.
-a, --all print all information, in the following order,
except omit -p and -i if unknown:
-s, --kernel-name print the kernel name
-n, --nodename print the network node hostname
-r, --kernel-release print the kernel release
-v, --kernel-version print the kernel version
-m, --machine print the machine hardware name
-p, --processor print the processor type or "unknown"
-i, --hardware-platform print the hardware platform or "unknown"
-o, --operating-system print the operating system
--help display this help and exit
--version output version information and exit
现在我们通过一个shell来展示下各个的对应关系:
# for option in s n m r v p i o; do echo -n "$option: "; uname -$option; done
s: Linux
n: parallels
m: x86_64
r: 3.10.0-862.11.6.el7.x86_64
v: #1 SMP Tue Aug 14 21:49:04 UTC 2018
p: x86_64
i: x86_64
o: GNU/Linux
////////////////////////////////////////////////////////////////
需要注意r: 3.10.0-862.11.6.el7.x86_64这个内核版本
3是内核版本
10表示主要修订
0表示小修
862代表最新的补丁
#1表示这个版本已经编译了1次(v: #1 SMP Tue Aug 14 21:49:04 UTC 2018)
////////////////////////////////////////////////////////////////
如果你需要知道你正在运行的发行版是什么版本,uname的输出不会给你太多帮助。内核版本毕竟和发行版不一样。为了获得这些信息,你可以在 Ubuntu 和其他基于 Debian 的系统上使用 lsb_release -r 命令,并显示 Red Hat 的 /etc/redhat-release 文件的内容。
举例在各个系统下命令
Red Hat or centos systems
# uname -a
Linux parallels 3.10.0-862.11.6.el7.x86_64 #1 SMP Tue Aug 14 21:49:04 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
# 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.5.1804 (Core)
Release: 7.5.1804
Codename: Core
# lsb_release -r
Release: 7.5.1804
# cat /etc/redhat-release
CentOS Linux release 7.5.1804 (Core)
For Debian systems:
$ lsb_release -r
Release: 20.04
For Red Hat and related systems:
$ cat /etc/redhat-release
Red Hat Enterprise Linux release 8.1 Beta (Ootpa)
Using /proc/version
The /proc/version file can also provide information on your Linux release. The information provided in this file has a lot in common with the uname -a output. Here are some examples.
On Ubuntu:
$ cat /proc/version
Linux version 5.4.0-37-generic (buildd@lcy01-amd64-001) (gcc version 9.3.0 (Ubuntu 9.3.0-10ubuntu2)) #41-Ubuntu SMP Wed Jun 3 18:57:02 UTC 2020
On RedHat:
$ cat /proc/version
Linux version 4.18.0-107.el8.x86_64 (mockbuild@x86-vm-09.build.eng.bos.redhat.com) (gcc version 8.3.1 20190507 (Red Hat 8.3.1-4) (GCC)) #1 SMP Fri Jun 14 13:46:34 UTC 2019
下面是macOS系统的
macOS系统
Show operating system name and more
➜ ~ uname -a
Darwin Mac 19.6.0 Darwin Kernel Version 19.6.0: Thu Jun 18 20:49:00 PDT 2020; root:xnu-6153.141.1~1/RELEASE_X86_64 x86_64 i386 MacBookPro15,1 Darwin
Show Mac OS X operating system version
➜ ~ sw_vers
ProductName: Mac OS X
ProductVersion: 10.15.6
BuildVersion: 19G2021
Show Apple hardware and software configuration
➜ ~ system_profiler 获取的信息量比较大,需要自己提取
system_profiler SPSoftwareDataType
Software:
System Software Overview:
System Version: macOS 10.15.6 (19G2021)
Kernel Version: Darwin 19.6.0
Boot Volume: Macintosh HD
Boot Mode: Normal
Computer Name: Mac
User Name: 隐藏哈
Secure Virtual Memory: Enabled
System Integrity Protection: Disabled
Time since boot: 3 days 23:53