Permissions and users
Linux commands: whoami
Learn how the Linux whoami command prints the user name currently logged in to your terminal session, and how it differs from the more detailed who am i.
8 minute lesson
whoami prints the effective user identity of the current process:
whoami

The word “effective” matters. After sudo, a container switch, or another privilege-changing tool, the process may run as a different user from the account that originally opened the session.
Compare these commands:
whoami
id
who am i
id shows the effective user ID, primary group, and supplementary groups. who am i reports the login session when that information is available; it is not a more detailed spelling of whoami.
This is a useful first diagnostic for permission errors. Before changing permissions, ask:
- Which user is the failing process actually running as?
- Which groups does it belong to?
- Who owns the file or socket it needs?
For example, a command that works under sudo but fails normally usually reveals an ownership, group, or configuration problem. Running everything as root hides that problem and increases the impact of mistakes.
Try it: run whoami and id, then inspect a file with ls -l. Explain whether your effective user can read, write, and execute it from the displayed permission bits.
Lesson completed