说明
今天突然想查看一下自己所使用的机器具体版本号,可是敲出了几个命令都没有查看版本,失望,又想起了一个通用的命令lsb_release -a,可是敲出这个后,居然报错-bash: lsb_release: command not found没有这个命令,真让我大吃一惊。看来还是百度一下吧,查看版本号这些不是经常使用的命令,在此做一个记录,方便以后翻看,这次rpm -q centos-release这个命令才让我查到了,感谢linuxidc。
0、辨识标准
首先要清楚什么样标识是32位的,什么样的是64位的。
PC server X86 系列、I386--I686等386、686 都是32位
只有标识x86_64 的才是 64位
1、查看位数命令
命令实在是不要太多,为了防止选择性障碍,一致选择第一种方式,后面的仅作为补充。
方法1:
[root@JiekeXu~]# uname -a
LinuxJiekeXu 3.10.0-327.18.2.el7.x86_64 #1 SMP Thu May 12 11:03:55 UTC 2016 x86_64x86_64 x86_64 GNU/Linux
方法2:显示系统程序信息
[root@JiekeXu~]# file /bin/ls
/bin/ls:ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (usesshared libs), for GNU/Linux 2.6.32,BuildID[sha1]=aa7ff68f13de25936a098016243ce57c3c982e06, stripped
方法3:
[root@JiekeXu~]# cat /proc/version
Linuxversion 3.10.0-327.18.2.el7.x86_64 ([email protected]) (gccversion 4.8.3 20140911 (Red Hat 4.8.3-9)(GCC) ) #1 SMP Thu May 12 11:03:55 UTC 2016
方法4:
(32位的系统中int类型和long类型一般都是4字节,64位的系统中int类型还是4字节的,但是long已变成了8字节inux系统中可用"getconf WORD_BIT"和"getconf LONG_BIT"获得word和long的位数。64位系统中应该分别得到32和64。)
[root@JiekeXu~]# getconf LONG_BIT
64
2、查看系统版本
方法1:
[root@JiekeXu~]# 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
DistributorID: CentOS
Description: CentOS Linux release 7.2.1511 (Core)
Release: 7.2.1511
Codename: Core
方法2:
[root@JiekeXu~]# cat /etc/os-release
NAME="CentOSLinux"
VERSION="7(Core)"
ID="centos"
ID_LIKE="rhelFedora"
VERSION_ID="7"
PRETTY_NAME="CentOSLinux 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"
方法3:
[root@JiekeXu~]# cat /etc/redhat-release
CentOSLinux release 7.2.1511 (Core)
方法4:
[root@JiekeXu~]# rpm -q centos-release
centos-release-7-1.1503.el7.centos.2.8.x86_64
3、查看内核版本
方法1:
[root@JiekeXu~]# cat /proc/version
Linuxversion 3.10.0-327.18.2.el7.x86_64 ([email protected]) (gccversion 4.8.3 20140911 (Red Hat 4.8.3-9) (GCC) ) #1 SMP Thu May 12 11:03:55 UTC2016
方法2:
[root@JiekeXu~]# uname -a
LinuxJiekeXu 3.10.0-327.18.2.el7.x86_64 #1 SMP Thu May 12 11:03:55 UTC 2016 x86_64x86_64 x86_64 GNU/Linux