查看 Linux 系统版本信息
一、前言
Linux 下如何查看内核信息、发行版信息,系统位数、CPU 信息等等,Windows 下我们可以通过各种图形化软件来查看,但是对于 Linux,我们需要使用相应的命令来获取这些信息。
二、查看系统信息
2.1 查看 Linux 内核版本
cat /proc/version
[root@ryan ~]# cat /proc/version Linux version 3.10.0-693.2.2.el7.x86_64 (builder@kbuilder.dev.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-16) (GCC) ) #1 SMP Tue Sep 12 22:26:13 UTC 2017
uname -a
[root@ryan ~]# uname -a Linux ryan 3.10.0-693.2.2.el7.x86_64 #1 SMP Tue Sep 12 22:26:13 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
2.2 查看 Linux 发行版本
cat /etc/issue,此命令也适用于所有的 Linux 发行版。
在之前的发行版中,版本信息在该文件是写固定的,可以直接查询到:
[root@ryan ~]# cat /etc/issue CentOS release 6.8 (Final) Kernel \r on an \m
之后的发行版中,该文件中的版本信息变成了参数的形式,已经查询不到了:
[root@ryan ~]# cat /etc/issue \S Kernel \r on an \m
cat /etc/redhat-release,这种方法只适合Redhat系的Linux:Redhat、CentOS、Fedora。
[root@ryan ~]# cat /etc/redhat-release CentOS Linux release 7.4.1708 (Core)
lsb_release -a,即可列出更多的版本信息,此命令适用于所有的 Linux。
[root@ryan ~]# lsb_release -a LSB Version: :core-4.1-amd64:core-4.1-noarch Distributor ID: CentOS Description: CentOS Linux release 7.4.1708 (Core) Release: 7.4.1708 Codename: Core
rpm -q centos-release,也可以查看发行版本信息,不常用,对应 RedHat 的命令为:rpm -q redhat-release
[root@ryan ~]# rpm -q centos-release centos-release-7-4.1708.el7.centos.x86_64
2.3 查看系统位数
getconf LONG_BIT,查看系统是 64 位还是 32 位。
32位的系统中int类型和long类型一般都是4字节,64位的系统中int类型还是4字节的,但是long已变成了8字节,Linux系统中可用"getconf WORD_BIT"和"getconf LONG_BIT"获得 word 和 long 的位数。64位系统中应该分别得到 32 和 64。
[root@ryan ~]# getconf LONG_BIT 64
2.4 查询 CPU 信息
cat /proc/cpuinfo,查看 cpu 相关信息,包括型号、主频等。
[root@ryan ~]# cat /proc/cpuinfo processor : 0 vendor_id : GenuineIntel cpu family : 6 model : 79 model name : Intel(R) Xeon(R) CPU E5-2682 v4 @ 2.50GHz stepping : 1 microcode : 0x1 cpu MHz : 2499.996 cache size : 40960 KB physical id : 0 siblings : 1 core id : 0 cpu cores : 1 apicid : 0 initial apicid : 0 fpu : yes fpu_exception : yes cpuid level : 13 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl eagerfpu pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm rdseed adx smap xsaveopt bogomips : 4999.99 clflush size : 64 cache_alignment : 64 address sizes : 46 bits physical, 48 bits virtual power management: