Today you will learn about a command which will help you to get information related to hardware and operating system.
In Linux, there are many commands, with the help of which we can extract information about hardware and software.
Here I have listed some of them:
- uname
- lshw
- lscpu
- lsblk
- lsusb
- dmidecode etc..
In this guide, I will explain to you about uname command.
Let’s get started.
uname
is a very basic but useful command that helps you get some key information’s like:
- Operating System Name
- Kernel Name and Version
- Kernel Release Information
- Network node Hostname/System Hostname
- System Hardware Name
- Processor Information
- Hardware Platform/Architecture details
First of all, let’s focus on some of the most important options that we can use with the uname
command.
Options | Explanation |
---|---|
-a, --all | Print all information. |
-s, --kernel-name | Print the kernel name |
-n, --nodename | Print the network node hostname |
-r, --kernel-release | Print the kernel release |
-v, --kernel-version | print the kernel version |
-m, --machine | Print the machine hardware name |
-p, --processor | print the processor type (non-portable) |
-i, --hardware-platform | print the hardware platform (non-portable) |
-o, --operating-system | Print the operating system |
--help | Display help page of uname Command |
--version | Check the version of uname command |
You must follow the syntax given below to use the uname
command.
uname [OPTION]...
Table of Contents
1. Print all Information
You can use -a
option to print all the information’s that the uname
command can provide.
In fact, you don’t need to remember any of uname
command’s other options. Only this option will provide you all the information.
~$ uname -a
Linux ubuntu 5.3.0-28-generic #30~18.04.1-Ubuntu SMP Fri Jan 17 06:14:09 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
As you can see, uname
has provided us with a lot of information related to hardware and software.
So let’s try to understand one by one.
Linux
: Kernel Nameubuntu
: Hostname of your System5.3.0-28-generic
: Kernel release Info.#30~18.04.1-Ubuntu SMP Fri Jan 17 06:14:09 UTC 2020
: Kernel Versionx86_64
: System Hardware Name/Architecturex86_64
: Processor Typex86_64
: Hardware PlatformGNU/Linux
: Operating System
You can also use the long option --all
.
~$ uname --all
2. Display the Hostname Name
To display the Hostname of your system pass the -n
option to uname
.
~$ uname -n
ubuntu
You can also use the long option --nodename
.
~$ uname --nodename
3. Display the Operating System Name
To display the Operating System name pass the -o
option to uname
.
~$ uname -o
GNU/Linux
You can also use the long option of this command --operating-system
.
~$ uname --operating-system
4. Print the Kernel Name using uname Command
To Print the Kernel name pass the -s
option to uname
Command.
~$ uname -s
Linux
Note: By default, uname
command prints the above output without any option.
~$ uname
Linux
You can also use the long option of this command --kernel-name
.
~$ uname --kernel-name
5. Print the Kernel Release Information
To Print the Kernel release information pass the -r
option to uname
.
~$ uname -r
5.3.0-28-generic
You can also use the long option of this command --kernel-release
.
~$ uname --kernel-release
6. Print the Kernel Version
To Print the Kernel Version pass the -v
option to uname
.
~$ uname -v
#30~18.04.1-Ubuntu SMP Fri Jan 17 06:14:09 UTC 2020
You can also use the long option --kernel-version
.
~$ uname --kernel-version
7. Display Machine Hardware Name/Architecture
To Print the Machine Hardware Name/Architecture pass the -m
option to uname
.
~$ uname -m
x86_64
You can also use the long option --machine
.
~$ uname --machine
8. Print the Processor type/Architecture
To Print the Processor type/Architecture pass the -p
option to uname
.
~$ uname -p
x86_64
You can also use the long option --processor
.
~$ uname --processor
9. Print the Hardware Platform
To Print the Hardware Platform pass the -i
option to uname
.
~$ uname -i
x86_64
You can also use the long option --hardware-platform
.
~$ uname --hardware-platform
10. Print multiple Information’s using uname Command
You can combine more than one option to print multiple information.
Let’s take some examples.
Task #1 – Print Kernel Name, Release Information, and Version.
~$ uname -srv
Linux 5.3.0-28-generic #30~18.04.1-Ubuntu SMP Fri Jan 17 06:14:09 UTC 2020
Task #2 – Print Hostname and Operating System name.
~$ uname -no
ubuntu GNU/Linux
11. Help/Manual page access
Use the following commands to access the Manual Page/Help Page of uname
command.
~$ uname --help
~$ man uname
12. Check the version of uname
Check the uname
command version using the following command.
~$ uname --version
Infographic
Refer to this Infographic for complete uname
command options.
You can visit at following websites to get more information on uname
command.
Conclusion
I hope you have learned something from this article.
I have tried my best to include all the features of uname command in this guide.
Now I’d like to hear your thoughts.
Was this guide useful to you?
Or maybe you have some queries.
Have I not included any command in this guide?