Skip to content
Advertisement

Linux Command to list all users by uid

I am using RedHat Linux 6. I need redhat Linux terminal code to list all the users above uid=499? i already tried “cat /etc/passwd”. but it shows all users. how do i filter it?

Advertisement

Answer

You can use awk to parse the passwd database for the UIDs you want.

To list all the users for UIDs strictly greater than 499, do this:

awk -F ':' '$3 > 499' /etc/passwd

EDIT: If you only want the usernames, do this:

getent passwd | awk -F: '$3 > 499 {print $1}'
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement