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

Intro To 'users' Command In Linux

2023-05-24 - By Robert Elder

     I use the 'users' command to list all of the users that are currently logged into the system:

users

     Here, you can see that I'm the only user who's logged in:

robert

Multiple Users Logged In

     If I log into this computer a second time with the postgres user, I'll see this user as well:

sudo -u postgres -i
users
postgres robert

     The 'users' command can show one user multiple times if they're logged in more than once using multiple methods such as through SSH or through terminal emulators:

users
robert robert

Specify A Different 'utmp' File

     By default, the users command will read information from the file at '/var/run/utmp':

users /var/run/utmp
robert robert

     This file contains information about currently logged in users but you can also specify the file at '/var/log/wtmp':

xxd /var/log/wtmp | head -n 10
00000000: 0100 0000 3500 0000 7e00 0000 0000 0000  ....5...~.......
00000010: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000020: 0000 0000 0000 0000 7e7e 0000 7275 6e6c  ........~~..runl
00000030: 6576 656c 0000 0000 0000 0000 0000 0000  evel............
00000040: 0000 0000 0000 0000 0000 0000 352e 3135  ............5.15
00000050: 2e30 2d35 332d 6765 6e65 7269 6300 0000  .0-53-generic...
00000060: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000070: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000080: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000090: 0000 0000 0000 0000 0000 0000 0000 0000  ................

     which contains more information about previously logged in users, so it produces many more results:

users /var/log/wtmp
postgres postgres postgres postgres postgres postgres postgres postgres postgres postgres robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert robert

     And that's why the 'users' 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