Linux / Unix: whoami Command Examples
The whoami command in Linux and Unix is used to display the name of the current user. Here are some common examples of how to use the whoami command:
- Display the name of the current user:
whoamiThis will display the name of the current user.
whoami command:$ whoami
johnrn
$ su
Password:
# whoami
rootIn the first example, the whoami command is run as the user john. In the second example, the user switches to the root user using the su command and then runs the whoami command to display the name of the current user (root).
