How to use whoami command in Linux ?
Linux
The "whoami" command is a command-line utility in Linux that allows users to determine their current user name. It is a useful utility for administrators who need to quickly determine which user is currently logged in on a particular machine.
Here at Fixwebnode , we shall look into a detailed overview of the "whoami " command and provide 6 practical examples of its usage.
Table of contents [Show]
What is whoami Command ?
The "whoami " command is a Linux command that is used to identify the user currently logged in to a given computer. It prints out the name of the user and the user's id. It is a useful utility for administrators who need to quickly determine which user is logged in on a particular machine.
whoami Command Syntax
The syntax for the “whoami” command is as follows:
$ whoami [options]
The command supports the following options:
- -h, --help: Display help information
- -V, --version: Display version information
- -a, --all-sessions: Display information about all sessions
- -s, --show-sysname: Display system name
Examples of using whoami Command
Now that we have covered the basics of the "whoami" command, let’s take a look at some practical examples.
1. Display User Name
To display the user name of the current user, simply run the following command:
$ whoami
This command will print out the name of the currently logged in user.
2. Display System Name
To display the system name, use the "--show-sysname" option:
$ whoami --show-sysname
This command will print out the system name.
3. Display Information About All Sessions
To display information about all sessions, use the "--all-sessions " option:
$ whoami --all-sessions
This command will print out information about all sessions.
4. Display Help Information
To display help information about the "whoami" command, use the "--help " option:
$ whoami --help
This command will print out help information about the command.
5. Display Version Information
To display version information about the "whoami" command, use the "--version " option:
$ whoami --version
This command will print out version information about the command.
The options can also be combined in order to achieve more complex results. For example, to display help information and version information at the same time, use the following command:
$ whoami --help --version
This command will print out both help information and version information.
[Need Tech support ? We can help you . ]