9 Linux Uname Command Examples to Get Operating System Details

Uname command is used to display basic information about the operating system and hardware. With options, Uname prints kernel details, and system architecture.

Uname is the short name for 'UNIX name'. Uname command works on all Linux and Unix like operating systems.

When you run Uname command without any options it just prints the core operating system name.

$ uname
Linux

uname without any options

In this tutorial, I will show you Uname options and show what information it provides about the system.

1) Kernel name

To reveal the kernel name, you can use -s parameter.

$ uname -s
Linux

The output will be the same with uname without parameter.

uname kernel name

2) Kernel release

If you need to know what kernel release you’re using, just use -r parameter

$ uname -r
2.6.18-371.1.2.el5

uname kernel version

3) Kernel version

Besides kernel information, uname can also fetch the kernel version. Use -v parameter for this purpose

$ uname -v
#1 SMP Tue Oct 22 12:57:43 EDT 2013

4) Nodename

The option -n (node name) will give you the system's hostname. For example, if your hostname is “dev-machine”, -n option will print 'dev-machine' as the output of -n parameter

$ uname -n
dev-machine

5) Hardware name

If you are wondering what kind of machine you’re using, you can try -m parameter. It will show you information about it.

$ uname -m
i686

The output i686 is indicating that your system is 32 bit operating system. If uname -m return x86_64, if you booted from 64 bit kernel, otherwise it returns i386.

6) Hardware platform

Similar with hardware name, -i option will show you hardware platform information.

$ uname -i
i386

The output i386 means you are running a 32 bit system. If the output is x86_64 it’s mean that you are running 64 bit system.

7) Processor type

To see the processor type (architecture), you can use -p option. If uname is not able to show you that information, it will show you ‘unknown’ in the output.

The arch command also prints the processor family type in Linux.

$ uname -p
i686

8) Operating system

Uname can also be used to reveal what operating system you are running. Use -o option to fulfill this purpose.

$ uname -o
GNU/Linux

But in order to find the distribution name and its version you need to look in the below files.

For RedHat and CentOS, you can also use '/etc/redhat_release' file.

$ cat /etc/redhat_release
CentOS release 5.10 (Final)

On other Linux distributions, you may use '/etc/issue'. Here's the example :

$ cat /etc/issue
Linux Mint Olivia \n \l

9) All information

There is one parameter that can reveal all the information. It’s -a parameter. It will show you all information except omit -i and -p if they are unknown.

$ uname -a
Linux dev-machine 2.6.18-371.1.2.el5 #1 SMP Tue Oct 22 12:57:43 EDT 2013 i686 i686 i386 GNU/Linux

uname all information

Conclusion

This tutorial we learned how to use uname command to get kernel, system, hardware and processor information, etc.

Uname, is a userspace request of a kernel service (system call) - uname(2). Some of the information can be found in '/proc/sys/kernel' and '/proc/version'.

/proc/sys/kernel/{ostype, hostname, osrelease, version, domainname}

You can write a kernel module to get uname information by including 'utsname.h' and calling the function utsname().

I hope you enjoyed reading and please leave your suggestion in the below comment section.

Read Also:

Pungki Arianto 11:06 am

Comments

Your email address will not be published. Required fields are marked *