I'm trying to find a Linux equivalent of running who -m
in Unix. In Unix, who -m
gives the first user ID you used to log in, before starting any new shell sessions through su
, etc.
The -m
switch to who
has a different effect in Linux, and I'm unable to find anything relevant to my needs in the man pages so far.
Update: My answer (who am i) is correct, your terminal is either broken or not configured correctly to support the functionality.
Based on the comments, I've done some more research and I asked a friend to help. You don't say which terminal you are using but it's likely doing the same thing as gnome-terminal.
In respect of gnome-terminal* when the terminal is started, it does not update the utmp file. This appears to be a design decision. Later when who reads utmp to find out the relevant information it's not there so it just exits and prints nothing.
* I tries xterm, konsole and ssh to various distros.
You want
who am i
which prints the invoking user as opposed towhoami
which tells you the username of the current effective userThat is buried in
info coreutils 'who invocation'
So interestingly (on a linux coreutils based system)who xyzzy plugh
works as well.