LOGNAME(1) User Commands LOGNAME(1)
logname - return user's login name
logname
The logname utility writes the user's login name to standard output.
The login name is the string that would be returned by the
getlogin(3C) function. If getlogin() does not return successfully,
the name corresponding to the real user ID of the calling process is
used instead. If a name cannot be found, the user's ID will be
printed.
See environ(7) for descriptions of the following environment
variables that affect the execution of logname: LANG, LC_ALL,
LC_CTYPE, LC_MESSAGES, and NLSPATH.
The following error values are returned:
0
Successful completion.
>0
An error occurred.
/etc/profile
environment for user at login time
/var/adm/utmpx
user and accounting information
See attributes(7) for descriptions of the following attributes:
+--------------------+-------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+--------------------+-------------------+
|Interface Stability | Committed |
+--------------------+-------------------+
|Standard | See standards(7). |
+--------------------+-------------------+
env(1), login(1), getlogin(3C), utmpx(5), attributes(7), environ(7),
standards(7)
October 25, 2019 LOGNAME(1)
NAME
logname - return user's login name
SYNOPSIS
logname
DESCRIPTION
The logname utility writes the user's login name to standard output.
The login name is the string that would be returned by the
getlogin(3C) function. If getlogin() does not return successfully,
the name corresponding to the real user ID of the calling process is
used instead. If a name cannot be found, the user's ID will be
printed.
ENVIRONMENT VARIABLES
See environ(7) for descriptions of the following environment
variables that affect the execution of logname: LANG, LC_ALL,
LC_CTYPE, LC_MESSAGES, and NLSPATH.
EXIT STATUS
The following error values are returned:
0
Successful completion.
>0
An error occurred.
FILES
/etc/profile
environment for user at login time
/var/adm/utmpx
user and accounting information
ATTRIBUTES
See attributes(7) for descriptions of the following attributes:
+--------------------+-------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+--------------------+-------------------+
|Interface Stability | Committed |
+--------------------+-------------------+
|Standard | See standards(7). |
+--------------------+-------------------+
SEE ALSO
env(1), login(1), getlogin(3C), utmpx(5), attributes(7), environ(7),
standards(7)
October 25, 2019 LOGNAME(1)