Linux / Unix: logname Command Examples To Display Loginname

Linux / Unix: logname Command Examples To Display Loginname

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:

refer to‮al:‬utturi.com
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.

Created Time:2017-10-29 22:09:00  Author:lautturi