Linux Command
logname
Print the name of the current terminal login user.
Summary
logname [OPTION]...
The main purpose
Options
--help Display help information and exit.
--version Display version information and exit.
return value
Returning 0 indicates success, returning a non-zero value indicates failure.
example
[root@localhost ~]# logname
root
Notice
-
Pay attention to distinguishing the two commands
whoamiandlogname; for example, we opened the terminal as userrootand then switched to useruser2. At this time,whoamireturns the current useruser2, andlognamereturnsroot. You can verify it by yourself. -
This command is a command in the
GNU coreutilspackage. For related help information, please seeman -s 1 logname,info coreutils 'logname invocation'.


