How does Linux `uname -m` get its information?

Solution 1:

You have to take into account that uname prints information from your software and hardware. Your 64-bit machine could be running a 32-bit Linux distribution.

uname -a prints this information (in order): kernel-name, nodename, kernel-release, kernel-version, machine, processor, hardware-platform, operating-system. If you see 64 bit hardware and i686 kernel, then you have installed a 32-bits Linux kernel.

For answering your whole question: uname is a system call and this command line tool is using it. You can check that easily runing strace uname -a

$ strace uname -a
execve("/bin/uname", ["uname", "-a"], [/* 23 vars */]) = 0
brk(0)                                  = 0x9fa6000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2b4abb365000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2b4abb366000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
...
...
...
uname({sys="Linux", node="my_pc", ...}) = 0
fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 0), ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2b4abe953000
uname({sys="Linux", node="my_pc", ...}) = 0
uname({sys="Linux", node="my_pc", ...}) = 0
write(1, "Linux my_pc 2.6.18-371.8.1.el5 "..., 99Linux my_pc 2.6.18-371.8.1.el5 #1 SMP Thu Apr 24 18:19:36 EDT 2014 x86_64 x86_64 x86_64 GNU/Linux
) = 99
close(1)                                = 0
munmap(0x2b4abe953000, 4096)            = 0
exit_group(0)                           = ?