Linux command of the day, 10 of 31 - who
who
I’m looking briefly at a Linux command every day for a month
Nice simple one today. who
tells me who is logged in to a system. It reads by default from a file (because Unix!) at /var/run/utmp
$ who
pi pts/0 2020-08-12 06:35 (192.168.1.159)
Here I’m logged in to a raspberry pi as user ‘pi’. I get a lot more info with the -a
flag and -H
to add headers, plus I log in again so I’ve got two users in:
$ who -aH
NAME LINE TIME IDLE PID COMMENT EXIT
system boot 1970-01-01 01:00
run-level 5 2020-08-09 18:38
LOGIN tty1 2020-08-09 18:38 501 id=tty1
pi + pts/0 2020-08-12 06:35 . 30980 (192.168.1.159)
pi + pts/1 2020-08-12 06:37 . 31058 (192.168.1.159)
Notes:
- I see the system was apparently ‘booted’ on the Unix epoch (?!)
- The + is the user
pi
‘s mesg status, i.e. whether the current user can write to that user’s tty. Let’s dig into that tomorrow|!
I have commands mesg
and tty
to quickly look those up:
$ mesg
is y
$ tty
/dev/pts/1
I log in twice, and for the user in pts/1 I set mesg n
then :
$ who -aH --lookup
NAME LINE TIME IDLE PID COMMENT EXIT
system boot 1970-01-01 01:00
run-level 5 2020-08-09 18:38
LOGIN tty1 2020-08-09 18:38 501 id=tty1
pi + pts/0 2020-08-12 06:35 . 30980 (192.168.1.159)
pi - pts/1 2020-08-12 06:37 . 31058 (192.168.1.159)
I tried to message the pi on pts/1 and get:
$ write pi pts/1
write: pi has messages disabled on pts/1