The logname
command is a Unix and Linux utility that displays the login name of the current user.
Here is the basic syntax for using the logname
command:
logname
The logname
command does not take any arguments. When you run the logname
command, it will display the login name of the current user.
For example:
$ logname user1
The logname
command reads the LOGNAME
environment variable to determine the login name of the current user. If the LOGNAME
variable is not set, the logname
command will try to determine the login name from the USER
environment variable, or from the PAM_USER
environment variable if it is set.
If the logname
command is unable to determine the login name of the current user, it will display an error message.