Linux for Developers
/Beginner
whoami
Definition
A command that prints the effective username of the currently logged-in user.
Explain Like I'm New
Looking at your own nametag. It tells you exactly who the computer thinks you are right now.
Real World Example
You SSH into a massive corporate server. You aren't sure if you logged in as yourself or as the admin. You type `whoami` and it prints `root`. You immediately become very careful.
Common Use Cases
- •Verifying active user
- •Scripting conditions (e.g., abort if not root)
Interview Questions
basic
- What will `whoami` output if you run it like this: `sudo whoami`?
intermediate
- What is the difference between the `whoami` command and the `who` command?