What does the whoami
command do in UNIX?
a) Displays the current username
b) Displays system information
c) Shows the current directory
d) Lists active processes
Answer:
a) Displays the current username
Explanation:
The whoami
command in UNIX displays the username of the currently logged-in user. This is useful when working in environments with multiple users or when using sudo
to run commands as a different user, as it confirms which user account is active.
For example, if you run whoami
, the output will show the username of the account under which the command was executed. This helps users verify their current session or switch between user accounts if necessary.
Using whoami
is important for managing user access and ensuring that commands are being executed with the correct permissions. It provides a simple but essential way to confirm your identity in a multi-user system.