如何判断 Linux 操作系统是 32 位还是 64 位

information technologylinux

许多用户对 Linux 系统究竟是 32 位 还是 64 位 感到困惑。众所周知,我们无法将 64 位 应用程序安装到 32 位 操作系统中。在重新安装 Linux 或清理 Linux 系统之前,我们应该确认 Linux 系统是 32 位还是 64 位。本文将指导您"如何判断 Linux 操作系统是 32 位还是 64 位"。

uname 命令

uname 是一个通用命令,它几乎适用于所有 Linux/Unix 操作系统。以下命令将显示您的 Linux 系统的操作系统类型 -

$ uname -a

示例输出应如下所示 –

$ uname -a
Linux linux 4.2.0-30-generic #35~14.04.1-Ubuntu SMP Fri Feb 19 14:48:13 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

dpkg 命令

dpkg 命令仅适用于基于 Debian 和 Ubuntu 的发行版及其衍生版本。以下命令将显示您的 Linux 系统的操作系统类型 -

$ dpkg --print-architecture

如果系统是 64 位,则结果应如下所示 –

amd64

如果系统是 32 位,则结果应如下所示 –

i386

getconf 命令

getconf 命令将显示系统配置变量。要显示操作系统信息,请使用以下命令 –

$ getconf LONG_BIT

示例输出应如下所示 –

$ getconf LONG_BIT
64

要了解更多信息,请参阅 ma​​n  命令 –

$ man getconf

示例输出应如下所示 –

GETCONF(1)          Debian GNU/Linux          GETCONF(1)
NAME
   getconf - Query system configuration variables
SYNOPSIS
   getconf -a
   getconf [-v specification] system_var
   getconf [-v specification] path_var pathname
DESCRIPTION
   -a
      Displays all configuration variables for the current system and their values.
   -v
      Indicate the specification and version for which to obtain configuration variables.

arch 命令

arch 命令 将显示您的操作系统类型,它与 uname -m 命令非常相似。如果输出结果为 x86_64,则表示它是 64 位操作系统;如果输出结果为 i686 或 i386,则表示它是 32 位操作系统。

命令应如下所示 –

$ arch

示例输出应如下所示 –

$ arch
x86_64

file 命令

file 命令加上特殊参数 /sbin/init 将显示操作系统类型。命令应显示如下 –

$ file /sbin/init

输出应如下所示 –

/sbin/init: ELF 64 位 LSB 共享对象,x86-64,版本 1 (SYSV),动态链接(使用共享库),适用于 GNU/Linux 2.6.24,BuildID[sha1]=7a4c688d009fc1f06ffc692f5f42ab09e68582b2,已剥离

上述命令解释了操作系统类型。从中可以看出,我们的系统是 64 位的。

恭喜!现在,您已经了解了"如何确定 Linux 操作系统是 32 位还是 64 位"。我们将在下一篇 Linux 文章中进一步学习这些类型的命令。继续阅读!


相关文章


有用资源