整理:如何看linux是32位还是64位

本文介绍了几种简单有效的方法来确定Linux系统的位数,包括检查核心文件、使用uname命令及getconf命令等。这些方法适用于不同版本的Linux系统,如Ubuntu。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

整理自:http://zhidao.baidu.com/question/584510453.html 和

http://blog.chinaunix.net/uid-26435987-id-3132332.html


一) file /sbin/init 或file /bin/ls 看是否有x86-64字样,没有的是32位

luye@ubuntu:~/software$ file /sbin/init
/sbin/init: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.15, stripped
luye@ubuntu:~/software$ 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.15, stripped


二)uname -a

luye@ubuntu:~/software$ uname -a
Linux ubuntu 2.6.32-21-generic #32-Ubuntu SMP Fri Apr 16 08:09:38 UTC 2010 x86_64 GNU/Linux

uname -a :显示系统名、节点名称、操作系统的发行版号、操作系统版本、运行系统的机器 ID 号。

uname -r :显示操作系统的发行版号
luye@ubuntu:~/software$ uname -r
2.6.32-21-generic

注:you may obtain the architecture for your machine with:

$ uname -m

With x86_64 representing a 64-bit (amd64) Linux kernel architecture and i386/i486/i586/i686 representing a 32-bit (i386) system.



三)getconf LONG_BIT
luye@ubuntu:~/software$ getconf LONG_BIT
64

关于该命令参见:http://blog.sina.com.cn/s/blog_4e5e0807010089qw.html

实践验证发现,除了上面的选项外其他都不可以使用,使用系统为Ubuntu:

luye@ubuntu:~/software$ getconf MODEL_CODE
getconf: Unrecognized variable `MODEL_CODE'
luye@ubuntu:~/software$ getconf KERNEL_BITCODE
getconf: Unrecognized variable `KERNEL_BITCODE'
luye@ubuntu:~/software$ getconf DISK_DEVNAME
getconf: Unrecognized variable `DISK_DEVNAME'
luye@ubuntu:~/software$ getconf DISK_SIZE /dev/hdisk0
getconf: Unrecognized variable `DISK_SIZE'


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值