From Bugzilla Helper: User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.1) Gecko/20021003 Description of problem: Problems with 'who' command. who -m who am i who mom likes do not return any results on my RHAT 8 system. man and info pages say these should return the session username. Version-Release number of selected component (if applicable): sh-utils-2.0.12-3 How reproducible: Always Steps to Reproduce: #! /bin/bash # Test the output of who, who -m, who am i, whoami, and who mom likes # All of these are documented to work; not all do in RHAT 8.0. echo "This is unadorned 'who'" who echo "This is 'who -m':" who -m echo "This is 'who mom likes':" who mom likes echo "This is 'who am i':" who am i echo "This is 'whoami':" whoami Actual Results: This is unadorned 'who' erik :0 May 22 11:55 This is 'who -m': This is 'who mom likes': This is 'who am i': This is 'whoami': erik Expected Results: Should have seen the username 'erik' in all cases. Additional info: No error messages. These options work as expected in previous versions of Red Hat Linux that I have used (5.2, 7.1, 7.3). Represents a regression of function (old scripts using who -m or who am i) would break.
Created attachment 91900 [details] Test script for 91442 Test script attached.
This is due to gnome-terminal not adding utmp entries. For example, try running who from inside an 'xterm -ls' window.
I confirmed that who works as expected in an xterm. Also works in gnome- terminal-2.2.1-3 (delivered in Red Hat 9).
Possible replacement from `who am i | awk '{print $1}'` (what most are looking for): ls -l `tty` | awk '{print $3}' Explanation below… On many systems "`who am i`" is equivalent to "`who -m`". The Problem here is that with some terminals, "who -m" returns nothing. Example #1 run from a xfce4-terminal Pegasus ~ # whoami root Pegasus ~ # who am i thomas pts/1 2017-08-19 11:15 (:0.0) Pegasus ~ # who -m thomas pts/1 2017-08-19 11:15 (:0.0) Pegasus ~ # who thomas tty8 2017-08-19 10:18 (:0) thomas pts/1 2017-08-19 11:15 (:0.0) thomas pts/5 2017-08-19 16:16 (:0.0) Pegasus ~ # who am i | awk '{print $1}' thomasPossible replacement from `who am i | awk '{print $1}'` (what most are looking for): ls -l `tty` | awk '{print $3}' Explanation below… On many systems "`who am i`" is equivalent to "`who -m`". The Problem here is that with some terminals, "who -m" returns nothing. Example #1 run from a xfce4-terminal Pegasus ~ # whoami root Pegasus ~ # who am i thomas pts/1 2017-08-19 11:15 (:0.0) Pegasus ~ # who -m thomas pts/1 2017-08-19 11:15 (:0.0) Pegasus ~ # who thomas tty8 2017-08-19 10:18 (:0) thomas pts/1 2017-08-19 11:15 (:0.0) thomas pts/5 2017-08-19 16:16 (:0.0) Pegasus ~ # who am i | awk '{print $1}' thomas Pegasus ~ # but Example #2 from a gnome-terminal (same computer, same commands) Pegasus ~ # whoami root Pegasus ~ # who am i Pegasus ~ # who -m Pegasus ~ # who thomas tty8 2017-08-19 10:18 (:0) thomas pts/1 2017-08-19 11:15 (:0.0) thomas pts/5 2017-08-19 16:16 (:0.0) Pegasus ~ # This seems to be a consequence of gnome-terminal not adding utmp entries… Pegasus ~ # but Example #2 from a gnome-terminal (same computer, same commands) Pegasus ~ # whoami root Pegasus ~ # who am i Pegasus ~ # who -m Pegasus ~ # who thomas tty8 2017-08-19 10:18 (:0) thomas pts/1 2017-08-19 11:15 (:0.0) thomas pts/5 2017-08-19 16:16 (:0.0) Pegasus ~ # This seems to be a consequence of gnome-terminal not adding utmp entries…