The uname and whoami commands in Linux

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.

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
Uname Default Output 1
uname command output

The “uname -a” option

The -a option gives the complete details of the system and the kernel in use in the following order:

  1. Kernel name
  2. Node name
  3. Kernel Release
  4. Kernel-Version
  5. Machine
  6. Processor (if known)
  7. Hardware platform (if known)
  8. 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 
Uname A Usage 1
uname -a command

In the above example:

  1. Kernel name – Linux
  2. Node name – HowLinux
  3. Kernel Release – 4.4.0-170-generic
  4. Kernel-Version – 199-Ubuntu SMP Thu Nov 14 01:45:04 UTC 2019
  5. Machine – x86_64
  6. Processor (if known) – x86_64
  7. Hardware platform (if known) – x86_64
  8. 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                                                                                                        
Uname S
uname -s option

2. uname -n for Nodename

root@HowLinux: ~# uname -n                                                                                                       
Uname N
uname -n output

3. uname -r for Kernel Release

root@HowLinux: ~# uname -r                                                                                                       
Uname R
uname -r for Kernel Release

4. uname -v for Kernel version

root@HowLinux: ~# uname -v                                                                                                       
#199-Ubuntu SMP Thu Nov 14 01:45:04 UTC 2019 
Uname V
uname -v output

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 is a very straightforward command 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, this command is of pretty much 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                                                                                                          
whoami command output