LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

logname

prints the user's login name

TLDR

Print login name
$ logname
copy

SYNOPSIS

logname [options]

DESCRIPTION

logname prints the name of the user who originally logged in on the controlling terminal. It uses the `getlogin` system call, which determines the login name from the session's utmp record rather than from environment variables (which cannot be trusted).Unlike whoami, which reports the current effective user, logname keeps showing the original login name after su or sudo switch the effective user.

PARAMETERS

--help

Display help information.
--version
Display version information.

INSTALL

sudo apt install coreutils
copy
sudo dnf install coreutils
copy
sudo pacman -S coreutils
copy
sudo apk add coreutils
copy
sudo zypper install coreutils
copy
brew install coreutils
copy
nix profile install nixpkgs#coreutils
copy

CAVEATS

Fails with "no login name" when there is no controlling terminal (for example in some cron jobs or daemons). 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)

Braincup
Open source brain training for math, memory and focus
Braincup mini-games
41 mini-games · Apache-2.0
No ads · No tracking
Play in browser
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid
276 stars
From the maker of Linux Command Library
Copied to clipboard
Braincup
Open source brain training for math, memory and focus. 41 mini-games, from mental arithmetic to Sudoku, N-Back and Solo Chess.
Apache-2.0 licensed · No ads · No tracking · No account
From the maker of Linux Command Library
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid