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
Published 2023-10-04 |
$1.00 CAD |
Intro To 'nproc' Command In Linux
Published 2023-07-15 |
Intro To 'comm' Command In Linux
Published 2023-09-06 |
How To Force The 'true' Command To Return 'false'
Published 2023-07-09 |
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
Published 2019-08-01 |
Intro To 'chroot' Command In Linux
Published 2023-06-23 |
Join My Mailing List Privacy Policy |
Why Bother Subscribing?
|