当我输入 uname -a
时,它会给出以下输出。
Linux mars 2.6.9-67.0.15.ELsmp #1 SMP Tue Apr 22 13:50:33 EDT 2008 i686 i686 i386 GNU/Linux
我如何知道给定的操作系统是 32 位还是 64 位?
这在编写 configure
脚本时很有用,例如:我要为什么架构构建?
最佳答案
试试 uname -m
.缺少 uname --machine
并输出:
x86_64 ==> 64-bit kernel
i686 ==> 32-bit kernel
否则,不是针对 Linux 内核,而是针对 CPU,您键入:
cat /proc/cpuinfo
或:
grep flags /proc/cpuinfo
在“flags”参数下,您将看到各种值:参见“What do the flags in /proc/cpuinfo mean?”
其中,一种名为lm
:Long Mode
(x86-64:amd64,也称为Intel 64,即64位)
lm ==> 64-bit processor
或using lshw
(如 below 所提到的 Rolf of Saxony ),没有 sudo
(仅用于 grepping cpu 宽度):
lshw -class cpu|grep "^ width"|uniq|awk '{print $2}'
注意:您可以在 64 位 CPU 上安装 32 位内核。
(正如 ysdx 在 his/her own answer 中提到的,“现在,系统可以是 multiarch 所以无论如何它没有意义。您可能想找到编译器的默认目标”)
关于linux - 如何确定给定的 Linux 是 32 位还是 64 位?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/246007/