15.0 如何得知Linux内核及CPU的位数 https://scz.617.cn/unix/201701171711.txt A: 检查Linux内核(OS)位数 1) # getconf LONG_BIT 64 另一种值是32 2) # arch # uname -m x86_64 如果是i686之类的,表示当前OS是32-bits的。不要用"uname -i"、"uname -p",这 两个的结果有可能是unknown。 检查CPU位数 1) # grep -w flags /proc/cpuinfo | sort -u | grep -w "lm" flags : ... rdtscp lm constant_tsc ... # grep -w flags /proc/cpuinfo | sort -u | grep -w -o "lm" lm 如果flags中出现"lm",表示CPU支持64-bits,lm是"long mode"的意思。这并不表示 OS是64-bits的。 没有"lm"并不意味着CPU不支持64-bits,据说存在新的支持64-bits的CPU,但没有 "long mode"。 2) # lshw -class processor -quiet | grep -w capabilities -m 1 capabilities: x86-64 fpu ... # lshw -class processor -quiet | grep -w capabilities | sort -u | grep -w -o "x86-64" x86-64 不推荐这个办法,太慢了 3) # dmidecode -t processor | grep -w Characteristics -m 1 -A 1 Characteristics: 64-bit capable -------------------------------------------------------------------------- dmidecode is a tool for dumping a computer's DMI (some say SMBIOS) table contents in a human-readable format. This table contains a description of the system's hardware components, as well as other useful pieces of information such as serial numbers and BIOS revision. Thanks to this table, you can retrieve this information without having to probe for the actual hardware. While this is a good point in terms of report speed and safeness, this also makes the presented information possibly unreliable. More often than not, information contained in the DMI tables is inaccurate, incomplete or simply wrong. -------------------------------------------------------------------------- dmidecode获取的信息依赖于BIOS实现,不可靠。 4) # lscpu Architecture: i686 CPU op-mode(s): 32-bit, 64-bit Byte Order: Little Endian CPU(s): 2 On-line CPU(s) list: 0,1 Thread(s) per core: 1 Core(s) per socket: 2 Socket(s): 1 ... # lscpu Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Byte Order: Little Endian CPU(s): 4 On-line CPU(s) list: 0-3 Thread(s) per core: 1 Core(s) per socket: 4 Socket(s): 1 ... 推荐这个办法 5) # hwinfo --cpu | grep -w Features | sort -u | grep -w -o "lm" lm