1.1. 查看系统版本
方法1:用lsb_release -a命令
[root@bogon ~]# 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.4.1708 (Core) Release: 7.4.1708 Codename: Core |
这个命令可以看到准确的系统版本
如果出现下面提示,说明没有安装lsb_release命令
bash: lsb_release: 未找到命令... |
安装lsb_release命令:
yum install -y redhat-lsb |
方法2:cat /etc/os-release命令
[root@bogon ~]# cat /etc/os-release NAME="CentOS Linux" VERSION="7 (Core)" ID="centos" ID_LIKE="rhel fedora" VERSION_ID="7" PRETTY_NAME="CentOS Linux 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:cat /etc/redhat-release命令
[root@bogon ~]# cat /etc/redhat-release CentOS Linux release 7.4.1708 (Core) |
这个命令效果同lsb_release -a,不过这个命令只显示系统版本
1.2. 查看内核版本
方法1:用cat /proc/version命令
[root@bogon ~]# cat /proc/version Linux version 3.10.0-693.el7.x86_64 (builder@kbuilder.dev.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-16) (GCC) ) #1 SMP Tue Aug 22 21:09:27 UTC 2017 |
方法2:用uname -a命令
[root@bogon ~]# uname -a Linux bogon 3.10.0-693.el7.x86_64 #1 SMP Tue Aug 22 21:09:27 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux |
1.3. 查看位数
这个就一种方式,最好判断,用getconf LONG_BIT。
32位的系统中int类型和long类型一般都是4字节,64位的系统中int类型还是4字节的,但是long已变成了8字节inux系统中可用"getconf WORD_BIT"和"getconf LONG_BIT"获得word和long的位数。64位系统中应该分别得到32和64。
也就说32位使用这两个命令得到的都是32,64位得到的32和64。
[root@bogon ~]# getconf WORD_BIT 32 [root@bogon ~]# getconf LONG_BIT 64 |
扩展请看https://blog.csdn.net/u011630575/article/details/51426429