linux - 如何确定给定的 Linux 是 32 位还是 64 位?

标签 linux shell 32bit-64bit processor

当我输入 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 位内核
(正如 ysdxhis/her own answer 中提到的,“现在,系统可以是 multiarch 所以无论如何它没有意义。您可能想找到编译器的默认目标”)

关于linux - 如何确定给定的 Linux 是 32 位还是 64 位?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/246007/

相关文章:

python - 64位python能否创建32位Windows可执行文件

nosql - 在 32 位架构上安装 RethinkDB

mysql - 如何使用 SQL 创建文件夹

c++ - 编写软件时 64 位优于 32 位的优势

linux - dlang是否默认安装一些信号处理程序

regex - 如果字符串包含关键字,则删除\n 换行符

linux - 访问另一台远程服务器Linux、Ubuntu的权限

c++ - --icon 选项不适用于 Qt > 5.5 中的 QApplication

linux - Shell 脚本中的文件写入缓冲

linux - ct : not yet implemented