Possible values for `uname -m`
Linux
(v4.12 - 2017-July)
Let's refer to the source of the newuname system call.
Tracking this down is complicated by the fact that Linux has UTS namespaces, but the init_uts_ns
machine
field is initialized by the UTS_MACHINE
macro, which is defined per-architecture.
Further complicating matters, machine
can be overridden via override_architecture()
, if the process is running under a 32-bit "compat" personality, to COMPAT_UTS_MACHINE
.
UTS_MACHINE
defaults in Makefile
to the same thing as ARCH
. However, many platforms have separate sub-architectures under the same arch
directory, so they set UTS_MACHINE
themselves
With the list of directories in arch/
and a little grep
-ing of the Linux kernel sources (git grep 'UTS_MACHINE\s*:='
and git grep COMPAT_UTS_MACHINE
), we can arrive at this list:
alpha
arc
arm
aarch64_be
(arm64
)aarch64
(arm64
)armv8b
(arm64
compat)armv8l
(arm64
compat)blackfin
c6x
cris
frv
h8300
hexagon
ia64
m32r
m68k
metag
microblaze
mips
(native or compat)mips64
(mips
)mn10300
nios2
openrisc
parisc
(native or compat)parisc64
(parisc
)ppc
(powerpc
native or compat)ppc64
(powerpc
)ppcle
(powerpc
native or compat)ppc64le
(powerpc
)s390
(s390x
compat)s390x
score
sh
sh64
(sh
)sparc
(native or compat)sparc64
(sparc
)tile
unicore32
i386
(x86
)i686
(x86
compat)x86_64
(x64
)xtensa
What are different possible values for POSIX::uname() release number on Windows?
On Windows, POSIX::uname
obtains its information from GetVersionEx
whose parameter's documentation contains a table.
The Win32 module provides more user-friendly calls.
>perl -MWin32 -E"say Win32::GetOSDisplayName()"
Windows 7 Professional (64-bit) Service Pack 1
Possible values for platform.machine()
On platforms with os.uname()
, this information comes directly from the result of that API call. That is to say, platform.machine()
returns the same thing as the uname -m
command.
Thus, the answer really depends on the kernel's implementation of the uname(2)
system call. For that, see this question and answer:
Possible values for `uname -m` (utsname.machine)
Possible Values For: PHP_OS
PHP passes through the uname, except on Windows (WINNT
) and Netware (Netware
). See Wikipedia for a non-exhaustive list of values not mentioned in your question:
- CYGWIN_NT-5.1
- IRIX64
- SunOS
- HP-UX
- OpenBSD (not in Wikipedia)
In Python, how do you determine whether the kernel is running in 32-bit or 64-bit mode?
How about working around issue7860
import os
import sys
import platform
def machine():
"""Return type of machine."""
if os.name == 'nt' and sys.version_info[:2] < (2,7):
return os.environ.get("PROCESSOR_ARCHITEW6432",
os.environ.get('PROCESSOR_ARCHITECTURE', ''))
else:
return platform.machine()
def os_bits(machine=machine()):
"""Return bitness of operating system, or None if unknown."""
machine2bits = {'AMD64': 64, 'x86_64': 64, 'i386': 32, 'x86': 32}
return machine2bits.get(machine, None)
print (os_bits())
Python: How to know if the OS/CPU is 64bits
Most information you are querying is determined by the wordsize of the interpreter, not the CPU.
Only platform.machine()
ignores this information; it is taken from the system uname -m
data instead, which is the recommended command to determine if your system is 64-bit for both Linux and OS X, and Windows provides the exact same information (Python uses the C uname()
function in all cases).
Either test for 64
in that string, or build a set of acceptable values:
'64' in platform.machine()
or
platform.machine() in {'x86_64', 'AMD64'}
Related Topics
How to Connect to the Fitbit Zip Over Bluetooth 4.0 Le on Linux with Bluez
How to Set Environment Variables on Ec2 Instance via User Data
How to Use Awk to Convert All the Lower-Case Letters into Upper-Case
Gdb Does Not Hit Any Breakpoints When I Run It from Inside Docker Container
Hardware Acceleration Without X
.Bashrc Not Read When Shell Script Is Invoked from Desktop Shortcut
Git Gui Like Bzr Explorer But for Git
How to Call a Function (Defined in Shell Script) in a Perl Script
Return Code When Os Kills Your Process
Renaming a Set of Files to 001, 002,
/Usr/Bin/Ld: Skipping Incompatible Foo.So When Searching for Foo
How to Change the Mime Type of a File from the Terminal
What Is Terminal Escape Sequence for Ctrl + Arrow (Left, Right,...) in Term=Linux
How to Give Highest Priority to Ethernet Interrupt in Linux
Tracking Threads Memory and CPU Consumption
How to Batch Resize Millions of Images to Fit a Max Width and Height