I am writing a program in Bash that needs to get the user\'s username.
I have heard of a thing called whoami, but I have no idea what it does or how to use it.
W
All,
From what I'm seeing here all answers are wrong, especially if you entered the sudo mode, with all returning 'root' instead of the logged in user. The answer is in using 'who' and finding eh 'tty1' user and extracting that. Thw "w" command works the same and var=$SUDO_USER gets the real logged in user.
Cheers!
TBNK