Looking up usernames based on uid in Linux

If you ever have the need to find out what username is matched with a uid number in linux here is a handy command to run:

perl -e '($login,$pass,$uid,$gid) = getpwuid(uidnumber);print "$login\n";'

Replace uidnumber with a real uid number (ie: 1002)

Leave a Reply