如何确定给定的 Linux 是 32 位还是 64 位? [英] How to determine whether a given Linux is 32 bit or 64 bit?

查看:31
本文介绍了如何确定给定的 Linux 是 32 位还是 64 位?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我输入 uname -a 时,它给出以下输出.

When I type uname -a, it gives the following output.

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 位?

How can I know from this that the given OS is 32 or 64 bit?

这在编写 configure 脚本时很有用,例如:我要为什么架构构建?

This is useful when writing configure scripts, for example: what architecture am I building for?

推荐答案

试试 <代码>uname -m.缺少 uname --machine 并输出:

x86_64 ==> 64-bit kernel
i686   ==> 32-bit kernel

<小时>

否则,不是针对 Linux 内核,而是针对 CPU,您输入:

cat /proc/cpuinfo

或:

grep flags /proc/cpuinfo

在flags"参数下,您将看到各种值:参见/proc/cpuinfo 中的标志是什么意思?

Under "flags" parameter, you will see various values: see "What do the flags in /proc/cpuinfo mean?" Among them, one is named lm: Long Mode (x86-64: amd64, also known as Intel 64, i.e. 64-bit capable)

lm ==> 64-bit processor

使用lshw(如下面 作者 Rolf of Saxony),没有 sudo(仅用于调整 CPU 宽度):

Or using lshw (as mentioned below by Rolf of Saxony), without sudo (just for grepping the cpu width):

lshw -class cpu|grep "^       width"|uniq|awk '{print $2}'

注意:您可以使用安装了 32 位内核的 64 位 CPU.
(如 ysdx他的/她自己的回答,如今,一个系统可以是multiarch 所以无论如何都没有意义.你可能想找到编译器的默认目标")

Note: you can have a 64-bit CPU with a 32-bit kernel installed.
(as ysdx mentions in his/her own answer, "Nowadays, a system can be multiarch so it does not make sense anyway. You might want to find the default target of the compiler")

这篇关于如何确定给定的 Linux 是 32 位还是 64 位?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆