whox
Show who is logged on.
Mirrors GNU who. Run it as whox, or as gnux whox.
Synopsis
whox [OPTION]... [ FILE | ARG1 ARG2 ]GNU reference
Description
whox lists the users logged in: name, terminal, login time and, for a remote session, the host in parentheses. -u adds how long each terminal has been idle ('.' under a minute, 'old' over a day) and the session's process ID, -T (or -w) whether the user accepts messages (+, - or ?), and -H a line of headings. -q prints just the names and their count. -b shows the last boot, -r the run level, -l login processes, -p processes started by init, -d dead processes and -t clock changes; -a shows all of them. -m (or any two operands, as in 'whox am i') shows only the terminal on standard input. --lookup turns host addresses into names. With FILE, the records are read from that utmp file (on Linux, /var/log/wtmp lists past logins too) instead of the current ones, and in the current ones, logins whose process has ended are left out. Times are in the C locale's 'Oct 12 09:30' format. The records are read without the C library, in each system's own format: Linux utmp, macOS utmpx and FreeBSD utx.active. On Windows, which keeps sessions rather than a utmp file, whox lists the signed-in console and Remote Desktop sessions, so the same command answers 'who is on this machine' everywhere; there FILE is not supported.
gnux's terminal view (BR-13): on a terminal, the records are a framed table with a header (-H's heading becomes it), the columns empty in every row left out, and your own logins in the theme's color for what is yours. -q is GNU's. --pretty[=WHEN] and --theme=NAME, options of gnux's own, choose the view (GNUX_PRETTY, GNUX_THEME); piped or redirected output is always GNU's.
Permissions
Needs read permission on the login records, which every user has.
Use cases
- Checking
whoelse is logged in to a shared server before rebooting it. - Seeing which remote hosts users are connected from.
- Finding idle sessions to clean up with
-u. - Checking when the machine last booted with
-b. - Counting logged-in users in a monitoring script with
-q.
Flags
-a, --all same as -b -d --login -p -r -t -T -u
-b, --boot time of last system boot
-q, --count all login names and number of users logged on
-d, --dead print dead processes
-H, --heading print line of column headings
--help display this help and exit
-l, --login print system login processes
--lookup attempt to canonicalize hostnames via DNS
-T, --mesg add user's message status as +, - or ?
--message same as -T
-m, --my-line only hostname and user associated with stdin
--pretty WHEN[="always"] the gnux terminal view WHEN: 'always' (the default when WHEN is omitted), 'auto' (the default: on a terminal only), or 'never'; GNUX_PRETTY sets the default
-p, --process print active processes spawned by init
-r, --runlevel print current runlevel
-s, --short print only name, line, and time (default)
--theme NAME color the view with the built-in theme NAME (gnux theme picks and saves one); GNUX_THEME sets the default
-t, --time print last system clock change
-u, --users list users logged in
--version output version information and exit
-w, --writable same as -TExamples
Before rebooting a shared server, see who is still logged in
whoxalice pts/0 Oct 12 09:30 (10.0.0.5)
bob pts/1 Oct 12 13:02 (laptop.lan)See how long each session has been idle, with headings
whox -uHNAME LINE TIME IDLE PID COMMENT
alice pts/0 Oct 12 09:30 01:30 1234 (10.0.0.5)
bob pts/1 Oct 12 13:02 . 1300 (laptop.lan)Check when the machine last booted
whox -b system boot Oct 9 10:44Count the logged-in users for a monitoring check
whox -qalice bob
# users=2Find out which terminal and login you are on
whox am ialice pts/0 Oct 12 09:30 (10.0.0.5)See who will receive a 'wall' broadcast (+ accepts messages)
whox -TShow every record, including dead processes and the run level
whox -aShow the remote hosts by name instead of address
whox --lookupReview past logins from the Linux login history
whox /var/log/wtmp | tailxWarn in a script when anyone besides you is logged in
[ "$(whox -q | tailx -n 1 | cutx -d= -f2)" -gt 1 ] && echox 'others are logged in'List logged-in users in the portable gnux shell, the same on every OS
gnux shell -c 'whox -q && uptimex'Options
Each option has a page of its own, with its usage and examples.
- -a, --all: Same as
-b -d --login -p -r -t -T -u. - -b, --boot: Time of last system boot.
- -q, --count: All login names and number of users logged on.
- -d, --dead: Print dead processes.
- -H, --heading: Print line of column headings.
- -l, --login: Print system login processes.
- --lookup: Attempt to canonicalize hostnames via DNS.
- -T, --mesg: Add user's message status as +, - or ?.
- --message: Same as
-T. - -m, --my-line: Only
hostnameand user associated with stdin. - --pretty: The
gnuxterminal view WHEN: 'always' (the default when WHEN is omitted), 'auto' (the default: on a terminal only), or 'never'; GNUX_PRETTY sets the default. - -p, --process: Print active processes spawned by init.
- -r, --runlevel: Print current runlevel.
- -s, --short: Print only name, line, and time (default).
- --theme: Color the view with the built-in theme NAME (
gnuxtheme picks and saves one); GNUX_THEME sets the default. - -t, --time: Print last system clock change.
- -u, --users: List users logged in.
- -w, --writable: Same as
-T.
Exit status
| Status | Meaning |
|---|---|
| 0 | success: every operand was processed |
| 1 | failure: an operand could not be processed (diagnosed on standard error), or a command-line mistake |
Help in the terminal
whox --help # options, first examples, exit status
gnux help whox # this page: the full manual
gnux help whox --OPTION # one option in depth, with its examples