Also, will these variables always match currently logged-in username (they do on my Debian system)? Can I assume their availability in other Unix(-like) systems?
I'm also curious why one would use whoami
instead of just reading any of these variables.
Best Answer
It's login.
The Linux login(1) man page says:
The FreeBSD login(1) man page says:
The NetBSD, OpenBSD and OS X man pages say the same thing.
Here's the source code from the util-linux login:
Here's the source code from the FreeBSD login: