This week’s Read the Manual is about id
: a tool I only learned the existence of while researching last week’s entry on lsof
! It gives you users’ user names, group names, and numeric IDs for a given user. This is handy when you need one of those pieces to pass to some other data — like the user ID.
If you just run id
, you get the user ID list for the current user. If you pass some other user name, you get the ID for that user.
The options are all just for variations on displaying the output, so this is pretty close to the Unix “do just one thing” philosophy. Some of those options:
-F
gives you the full name of the user (id -F
→Chris Krycho
on my Mac)-G
gives you the group IDs for the user, as numbers, “in no particular order”-g
gives you the effective group ID as a number-u
gives you the effective user ID as a number-n
is a very helpful modifier for the-G
,-g
, and-u
flags because it gives you the name of those values. Soid -u
gives me501
, butid -un
gives mechris
. Handy.-r
is likewise a modifier on other flags; it gives you real rather than effective group or user IDs.
I don’t honestly know when I would need almost any of these, other than when trying to chase down some very weird system behavior — probably in conjunction with tools like ps
and lsof
, or even htop
or procs
.
Have you ever had cause to use them? I’d love to hear some details!