The uname and whoami commands help you understand details like kernel version, name, hostname, etc of the Linux system you are using and what user is currently logged in. Simple yet useful, both the commands are very commonly used by Linux administrators and users alike who work with multiple Linux systems.
Also read: How to Use ls Command in Linux/Unix
The uname command in Linux
The uname command stands for Unix name. When you use
uname without any options, the command reports the name of the system kernel that the command is being run on.
root@tryit-fluent:~# uname Linux
The “uname -a” option
The -a option gives the complete details of the system and the kernel in use in the following order:
- Kernel name
- Node name
- Kernel Release
- Processor (if known)
- Hardware platform (if known)
- Operating System
root@HowLinux:~# uname -a Linux howlinux 4.4.0-170-generic #199-Ubuntu SMP Thu Nov 14 01:45:04 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
In the above example:
- Kernel name – Linux
- Node name – HowLinux
- Kernel Release – 4.4.0-170-generic
- Kernel-Version – 199-Ubuntu SMP Thu Nov 14 01:45:04 UTC 2019
- Machine – x86_64
- Processor (if known) – x86_64
- Hardware platform (if known) – x86_64
- Operating System – GNU/Linux
Print system details individually using options
You can also print each individual detail without having to see all the other information by using options.
1. uname -s for Kernel Name (same output as writing uname without options)
root@HowLinux:~# uname -s Linux
2. uname -n for Nodename
root@HowLinux: ~# uname -n HowLinux
3. uname -r for Kernel Release
root@HowLinux: ~# uname -r 4.4.0-170-generic
4. uname -v for Kernel version
root@HowLinux: ~# uname -v #199-Ubuntu SMP Thu Nov 14 01:45:04 UTC 2019
5. Some other options
- -m, –machine print the machine hardware name
- -p, –processor print the processor type or “unknown”
- -i, –hardware-platform print the hardware platform or “unknown”
- -o, –operating-system print the operating system
- –help display this help and exit
- –version output version information and exit
The whoami command in Linux
The whoami command in Linux is straightforward with no customization options. The sole purpose of the command is to find out which user you’re currently logged in as.
On single-user systems, the whoami command in Linux is of no use. But, when working with multiple systems, sudo-ing through multiple users, ssh-ing in multiple systems, you will tend to get lost at times as to what user is currently in use.
root@HowLinux:~# whoami root
What does the command uname print when you run it without any option?
When used without any options, the uname command will print the Kernel name.
What is whoami command in Linux used for?
The whoami command helps you identify the username that you’re logged in as. This is especially useful for system admins who work on multiple devices while logging in through SSH.
Both the uname and whoami commands can be handy when you’re working with multiple systems. It helps you identify the machine you’re working on and the privileges you have. While we’re on the topic of multiple systems, here’s an article you can read next on using ssh to connect to remote systems.