Linux command
whoami 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Print the current username
whoami
说明
whoami prints the username associated with the current effective user ID. It's equivalent to id -un. This is useful in scripts to determine which user is running the script, especially when the script might be run via sudo or after using su to switch users. Unlike who am i which shows the login name from utmp, whoami shows the effective user ID name, which may differ after sudo or su.
参数
- --help
- Display help and exit
- --version
- Display version and exit
FAQ
What is the whoami command used for?
whoami prints the username associated with the current effective user ID. It's equivalent to id -un. This is useful in scripts to determine which user is running the script, especially when the script might be run via sudo or after using su to switch users. Unlike who am i which shows the login name from utmp, whoami shows the effective user ID name, which may differ after sudo or su.
How do I run a basic whoami example?
Run `whoami` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does --help do in whoami?
Display help and exit