Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Where does Linux uname -m get its information from?

I am asking because I have a machine that is 64-bits for sure, and uname -a and uname -r confirm that, but uname -m prints i686. Where does it get that from??

share|improve this question

1 Answer 1

up vote 20 down vote accepted

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)                           = ?
share|improve this answer
2  
Use strace -v to see the full uname return values. –  grawity Jun 2 at 12:43
    
I've been using Linux and UNIX for the last 4 years and had no idea about strace. I wonder whether it uses ptrace under the hood... If only there were a program that allowed me to easily check! ;) –  Parthian Shot Jun 2 at 19:22
1  
@ParthianShot It is using ptrace. To verify, use strace strace uname -a. And direct the output to a file so you can comfortably read it. –  tbodt Jun 2 at 19:39
    
@tbodt Good stuff... Thanks! :) –  Parthian Shot Jun 2 at 19:45
    
@ParthianShot And they haven't even mentioned ltrace yet. :) –  oakad Jun 3 at 1:33

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.