Linux uname Command Tutorial for Beginners (8 Examples)

Regardless of whether you are a system admin, software developer, or a normal Linux user, you may find yourself in a situation where you need some system information like kernel release or version. Well, there exists a built-in command line utility - dubbed uname - that lets you do this.

In this tutorial, we will discuss the basics of this tool using some easy to understand examples. But before we do that, it's worth mentioning that all examples in the article have been tested on an Ubuntu 14.04 LTS machine.

Linux uname command

As already mentioned, the uname command gives you system information. Following is its syntax:

uname [OPTION]...

And here's how the man page defines it:

Print certain system information.

Following are some Q&A-styled examples that should give you a good idea of how uname works.

Q1. How to use uname?

For basic usage, just execute the 'uname' command sans options.

uname

On my system, the above command produced the following output:

Linux

Q2. How to print kernel name?

For this, use the -s command line option.

uname -s

The output on my system was:

Linux

So you can see this it's the kernel name that the uname command produces by default as well (when no options are passed).

Q3. How to print kernel release?

Use the -r option for this.

uname -r

For example, on my system, the following output was produced:

4.4.0-62-generic

Q4. How to print kernel version?

Kernel version can be accessed by using the -v command line option.

uname -v

Here's the output from my machine:

#83~14.04.1-Ubuntu SMP Wed Jan 18 18:10:26 UTC 2017

Q5. How to print network node hostname?

The -n command line option lets you print this info.

uname -n

For example, following is the output the above command produced on my system:

himanshu-desktop

Q6. How to print machine hardware name?

The -m option allows uname to print the machine hardware name.

uname -m

Here's the output the above command produced on my system:

i686

Q7. How to print processor type?

To get processor type in output, use the -p command line option.

uname -p

On my system, the following output was produced:

athlon

Q8. How to print hardware platform?

Information related to hardware platform can be accessed using the -i option.

uname -i

On my system, the output was same as what it was in case of the -m command line option - i686.

Q9. How to print operating system?

Use the -o command line option in case you want to fetch the OS name.

uname -o

Following output was produced on my Ubuntu machine:

GNU/Linux

Q10. How to print all information in one go?

If you wish, you can also print all the information - that we've accessed through individual options so far - in one go. For this, use the -a option.

uname -a

Here's the output produced on my system:

Linux himanshu-desktop 4.4.0-62-generic #83~14.04.1-Ubuntu SMP Wed Jan 18 18:10:26 UTC 2017 i686 athlon i686 GNU/Linux

Conclusion

As you'd agree, uname is a command that's fairly easy to understand and use. The only thing you need to keep in mind is its command line options - when to use which. Practice the options we've discussed in this tutorial, and for more info on the tool, head to its man page.

Share this page:

Suggested articles

0 Comment(s)

Add comment