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.
Here are some examples of using the whoami command:
$ whoami
john
$ su
Password:
# whoami
root
In 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).
