Robert Elder Software Inc.
  • Home
  • Store
  • Blog
  • Contact
  • Home
  • Store
  • Blog
  • Contact
  • #linux
  • |
  • #commandline
  • |
  • #softwareengineering
  • |
  • #embeddedsystems
  • |
  • #compilers
  • ...
  • View All >>

Intro To 'who' Command In Linux

2023-06-01 - By Robert Elder

     I use the who command to see who's logged in:

who
robert   :0           2023-05-29 09:28 (:0)

Process, User And Display Information

     I can use the '-a' flag with the 'who' command to see other useful information as well, including the system boot time and the current run level:

who -a
           system boot  2023-05-29 09:28
           run-level 5  2023-05-29 09:28
robert   ? :0           2023-05-29 09:28   ?          2529 (:0)

     If I open another terminal and start tmux as the postgres user, I'll see an additional entry for this user:

# In another terminal
sudo -u postgres -i
tmux
who -a
           system boot  2023-05-29 09:28
           run-level 5  2023-05-29 09:28
robert   ? :0           2023-05-29 09:28   ?          2562 (:0)
           pts/2        2023-05-29 09:28   ?         60014 id=ts/2  term=0 exit=0
postgres + pts/3        2023-05-29 11:51   .         63417 (tmux(63417).%0)

     Here, I can see that the 'robert' user is currently using the graphical display session at ':0' with process ID 2562, and the postgres user is using pseudo terminal 3 and has process ID 63417.

Historical Login Information

     By default, the 'who' command sources information from this file:

who -a /var/run/utmp
           system boot  2023-05-29 09:28
           run-level 5  2023-05-29 09:28
robert   ? :0           2023-05-29 09:28   ?          2529 (:0)
postgres + pts/4        2023-05-29 11:51 00:04       21567 (tmux(21567).%0)

     but you can also specify this file:

who -a /var/log/wtmp
           run-level 5  2022-11-25 09:00
robert   ? :0           2022-11-25 09:00   ?          2585 (:0)
           run-level    2022-11-26 00:23
           system boot  2022-11-26 08:46
           run-level 5  2022-11-26 08:47
robert   ? :0           2022-11-26 08:47   ?          2613 (:0)
           run-level    2022-11-27 00:13
           system boot  2022-11-27 08:26
           run-level 5  2022-11-27 08:26
robert   ? :0           2022-11-27 08:27   ?          2625 (:0)
...Many hundreds of lines...

     which includes more historical information.

Granular Information

     The 'who' command supports many other flags to selectively display and format its output:

who -b
who -d
who --login
who -p
who -r
who -t
who -T
who -u
         system boot  2023-05-29 09:28
         run-level 5  2023-05-29 09:28
robert   ? :0           2023-05-29 09:28 (:0)
postgres + pts/4        2023-05-29 11:51 (tmux(21567).%0)
robert   :0           2023-05-29 09:28   ?          2529 (:0)
postgres pts/4        2023-05-29 11:51 00:05       21567 (tmux(21567).%0)

     And that's why the 'who' command is my favourite Linux command.

Intro To 'stty' Command In Linux
Intro To 'stty' Command In Linux
Published 2023-10-04
Terminal Block Mining Simulation Game
$1.00 CAD
Terminal Block Mining Simulation Game
Intro To 'nproc' Command In Linux
Intro To 'nproc' Command In Linux
Published 2023-07-15
Intro To 'comm' Command In Linux
Intro To 'comm' Command In Linux
Published 2023-09-06
How To Force The 'true' Command To Return 'false'
How To Force The 'true' Command To Return 'false'
Published 2023-07-09
A Surprisingly Common Mistake Involving Wildcards & The Find Command
A Surprisingly Common Mistake Involving Wildcards & The Find Command
Published 2020-01-21
A Guide to Recording 660FPS Video On A $6 Raspberry Pi Camera
A Guide to Recording 660FPS Video On A $6 Raspberry Pi Camera
Published 2019-08-01
Intro To 'chroot' Command In Linux
Intro To 'chroot' Command In Linux
Published 2023-06-23
Join My Mailing List
Privacy Policy
Why Bother Subscribing?
  • Free Software/Engineering Content. I publish all of my educational content publicly for free so everybody can make use of it.  Why bother signing up for a paid 'course', when you can just sign up for this email list?
  • Read about cool new products that I'm building. How do I make money? Glad you asked!  You'll get some emails with examples of things that I sell.  You might even get some business ideas of your own :)
  • People actually like this email list. I know that sounds crazy, because who actually subscribes to email lists these days, right?  Well, some do, and if you end up not liking it, I give you permission to unsubscribe and mark it as spam.
© 2025 Robert Elder Software Inc.
SocialSocialSocialSocialSocialSocialSocial
Privacy Policy      Store Policies      Terms of Use