How to use the whoami command in linux

小老鼠
Release: 2024-04-18 16:18:14
Original
1498 people have browsed it

The whoami command is used to display the username and group of the currently logged in user. Syntax: whoami. Output: Current username. Variants: whoami -u (username only), whoami -g (group only), whoami -p (PID only). Built-in command used to determine the identity of the user when running the command.

How to use the whoami command in linux

whoami command in Linux

What is the whoami command?

The whoami command is a command used to display the username and group of the currently logged in user in a Linux system.

How to use the whoami command?

The syntax of the whoami command is very simple:

<code>whoami</code>
Copy after login

Command output

After executing the whoami command, you will see the following output:

<code>当前用户名</code>
Copy after login

You can also get additional information using the following variations:

  • whoami -u: Show only the current username.
  • whoami -g: Only displays the current user's belonging groups.
  • whoami -p: Only displays the process ID (PID) of the current user.

Example

The following example shows how to use the whoami command:

<code>$ whoami
alice</code>
Copy after login

This means that the current logged in user name is alice.

Additional Information

  • The whoami command is a built-in command, which means it does not require any external program.
  • The whoami command is useful for determining who you are when running commands on your system.
  • The whoami command can also be used as a simple way to check a user's identity in a script.

The above is the detailed content of How to use the whoami command in linux. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template