Hi! If you're new here, you may want to subscribe to the Unix Tutorial RSS feed to get regular tips & tricks for all flavors of Unix. Thanks for visiting!
There's quite a few ways to confirm a user ID (uid) in Unix.
id command
This is probably one of the easiest ways to find out a uid of a particular user in your system:
# id -u greys 500
The most common way of using the id command is even simpler, and it gives you all the information about a user you may need:
# id greys uid=500(greys) gid=500(greys) groups=500(greys)
This not only shows you the user id (uid), but also confirms user's group id (gid) and all the rest Unix groups a user belongs to.
getent
Another way to get information about a user (including uid) is to use the getent command:
# getent passwd greys greys:x:500:500:Gleb Reys:/home/greys:/bin/bash
In this example, greys is my username, 500 is the uid, and the second 500 in this line is my Unix group id (gid).
/etc/passwd file
If you know that the user you're looking at is a local user (it is created on the local Unix system of yours), you can grep for it in /etc/passwd file directly:
$ grep greys /etc/passwd
greys:x:500:500:Gleb Reys:/home/greys:/bin/bash












2 comments ↓
[...] ← How To Find Out User ID in Unix [...]
[...] Thanks for visiting!Finding out the username by user id (uid) in Unix is not as common a task as determining the uid by a username, but if you need to do it - I'll show you [...]
Leave a Comment