NAME
logname
—
get session login name
SYNOPSIS
logname |
DESCRIPTION
Writes the result of getlogin(3), followed by a newline, to the standard output stream.
EXIT STATUS
1 if
getlogin
() failed.
SEE ALSO
STANDARDS
Conforms to IEEE Std 1003.1-2024
(“POSIX.1”) — the non-normative section specifies that
it should ignore the LOGNAME
environment variable,
as the environment may be neither trusted nor consistent, but
getlogin(3) is itself allowed to return
LOGNAME
, and some implementations do.
HISTORY
Appeared in Programmer's Workbench
(PWB/UNIX), writing logname
() (which read it from
PWB-specific per-process inherited private user data;
loginfo(II)).
AT&T System III UNIX inherits
it, but with logname
() returning
LOGNAME
.
AT&T System V Release 1
UNIX logname
writes
cuserid(3) (either
getlogin(3), or the username of the current
UID), where
getlogin(3) reads the
utmp(5) entry corresponding to the teletype attached the
standard input, output, or error stream.
X/Open Portability Guide (“XPG”) imports AT&T System V Release 1 UNIX getlogin(3C), explicitly requiring utmp(5) parsing.
X/Open Portability Guide Issue 2
(“XPG2”) standardises logname
verbatim
as "the user's login name".
IEEE Std 1003.2-1992
(“POSIX.2”) narrows it to
getlogin
() only.