Get Current Username in Linux
To get current username in Linux, we can use whoami command.
whoami
Example 1 – Username of root user
In this example, we will get the user name of the root user.
![](https://www.tutorialkart.com/wp-content/uploads/2023/03/linux-print-current-username-1.png)
We are currently logged in as root.
root@tutorialkart#
To get the user name of the root user, execute the whoami command.
root@tutorialkart# whoami root
ADVERTISEMENT
Example 2 – Username of another user
In this example, we will get the user name of another user.
![](https://www.tutorialkart.com/wp-content/uploads/2023/03/linux-print-current-username-2.png)
Now we have logged in as another user, say prasanna.
prasanna@tutorialkart:/tutorialkart$
Let us get the user name of this user using whoami command.
prasanna@tutorialkart:/tutorialkart$ whoami prasanna
Conclusion
In this Linux Tutorial, we learned how to get the user name of current user using whoami command.