LinuxCommandLibrary

logname

prints the user's login name

TLDR

Print login name

$ logname
copy

SYNOPSIS

logname [options]

DESCRIPTION

logname prints the user's login name. It reads from the utmp file to determine the original login.
Unlike whoami, logname shows the login name even after su or sudo commands.

PARAMETERS

--help

Display help information.
--version
Display version information.

CAVEATS

May fail if not run from a terminal. Differs from whoami after su. POSIX standard command.

HISTORY

logname is a traditional Unix command from POSIX, showing the name used to log into the system.

SEE ALSO

whoami(1), who(1), id(1)

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard