Is there a monitor like
top but for the
who) command? It's ok if it's a package that needs to be installed. Any Linux flavor. I'd like to have a simple CLI real-time monitor of users logged into the system along with what they're doing. TIA
You have several possibilities. Those that come to my mind immediately are all based in the idea to periodically execute the
w command (hence, strictly speaking they are no real-time monitors, but top also refreshes the current processes only periodically):
Shell based (bash syntax)
Infinite loop that executes
while true; do clear w sleep 1 done
There's also a dedicated program for that purpose, called
watch -n 1 "w"
While possibility 1 and 2 usually work out-of-the-box on a standard GNU/Linux system, there is also a program called
multitail. Although in the first place designed for another purpose,
The program MultiTail lets you view one or multiple files like the original tail program. The difference is that it creates multiple windows on your console (with ncurses). It can also monitor wildcards: if another file matching the wildcard has a more recent modification date, it will automatically switch to that file.
it can also execute a program periodically:
multitail -r 1 -l "w"
multitail can also highlight the differences compared to the previous run, please check the man pages for the corresponding (and much more) options.
The last command acts by reading /var/log/wtmp. You can set up a watch on it by means ofinotifywait(part of the package *inotify-tools) as follows:
while inotifywait -e close_write /var/log/wtmp ; do /path/to/executable/script; done
where /path/to/executable/script is some a script (made executable by chmod 755 script) which will do some highly noticeable action to attract your attention, see here for some suggestions.