美文网首页
Linux系统位数和系统版本查看

Linux系统位数和系统版本查看

作者: 明翼 | 来源:发表于2020-05-02 11:29 被阅读0次

有时候我们需要知道现在运行的环境是 32 位系统还是 64 位系统还有具体使用什么版本,可以用 linux 的命令来查看下,都有哪些比较简单的办法那,这里做个小小的总结。

一 Linux系统位数查看

1.1 Cat查看

[root@localhost testcode]# 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

x86_64即为64位的,如果出现i386或i686等为32位系统。

cat /proc/cpuinfo | grep flags | grep ' lm ' | wc -l

根据cpu的flag判断是不是有lm标识,有代表是64位linux系统。

1.2 查看应用程序版本

[root@localhost testcode]# file /bin/ls
/bin/ls: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=3d705971a4c4544545cb78fd890d27bf792af6d4, stripped

显示ls为 64-bit可执行程序,显然应该是64位系统。

1.3 uname查看

这个方法,我用的最多,命令如下:

[root@localhost ~]# uname -m
x86_64

1.4 getconf命令

此命令可以获得系统的基本信息,比如内存大小,磁盘大小,以及系统位数等。

[root@localhost ~]# getconf  LONG_BIT 
64

这个方法很直观,却很少用,主要了解不够多。

1.5用arch命令

[root@localhost ~]# arch
x86_64

二 操作系统版本信息获取

2.1 最常用的uname

[root@localhost ~]# uname -a
Linux localhost.localdomain 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

这样命令看也可以看出来是linux系统,64位,以及内核版本等,el企业版linux。
比较乱不如:

[root@localhost ~]# uname -m
x86_64
[root@localhost ~]# uname -r
3.10.0-693.el7.x86_64
[root@localhost ~]# uname -s
Linux
[root@localhost ~]# uname -v
#1 SMP Tue Aug 22 21:09:27 UTC 2017
[root@localhost ~]# uname -i
x86_64
[root@localhost ~]# uname -p
x86_64

说明:

-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

2.2 lsb_release

 [root@localhost testcode]# 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

如果没有可以安装下:

[root@localhost testcode]# yum install -y redhat-lsb
Loaded plugins: fastestmirror, langpacks

2.3 Cat查看

只适合于redhat类的

[root@localhost testcode]#  cat /etc/redhat-release
CentOS Linux release 7.4.1708 (Core) 

[root@localhost testcode]#  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

这两个命令不错,可以看到具体的系统版本详细信息。

相关文章

网友评论

      本文标题:Linux系统位数和系统版本查看

      本文链接:https://www.haomeiwen.com/subject/agtkghtx.html