Linux uname Command Tutorial for Beginners (8 Examples)
On this page
- Linux uname command
- Q1. How to use uname?
- Q2. How to print kernel name?
- Q3. How to print kernel release?
- Q4. How to print kernel version?
- Q5. How to print network node hostname?
- Q6. How to print machine hardware name?
- Q7. How to print processor type?
- Q8. How to print hardware platform?
- Q9. How to print operating system?
- Q10. How to print all information in one go?
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:
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.
On my system, the above command produced the following output:
Q2. How to print kernel name?
For this, use the -s command line option.
The output on my system was:
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.
For example, on my system, the following output was produced:
Q4. How to print kernel version?
Kernel version can be accessed by using the -v command line option.
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.
For example, following is the output the above command produced on my system:
Q6. How to print machine hardware name?
The -m option allows uname to print the machine hardware name.
Here's the output the above command produced on my system:
Q7. How to print processor type?
To get processor type in output, use the -p command line option.
On my system, the following output was produced:
Q8. How to print hardware platform?
Information related to hardware platform can be accessed using the -i option.
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.
Following output was produced on my Ubuntu machine:
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.
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
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.