LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   by which command, I can look up a user name by inputing UID, (https://www.linuxquestions.org/questions/linux-newbie-8/by-which-command-i-can-look-up-a-user-name-by-inputing-uid-710420/)

andy820303 03-10-2009 02:10 AM

by which command, I can look up a user name by inputing UID,
 
Similarly, I can use "id user_name" to get the corresponding UID, so backwards, do I have a way to look up a user_name by the corresponding UID?

Thanks
Andy

rizwanrafique 03-10-2009 03:16 AM

Not sure about any such command but you can easily find it by doing:

Code:

grep "^user:" /etc/passwd|cut -f 3 -d ":"
Replace user with the username you want to lookup.

your_shadow03 03-10-2009 03:17 AM

man id

Code:

.....
.....
      -n, --name
              print a name instead of a number, for -ugG
.....
.....


andy820303 03-10-2009 11:51 PM

Quote:

Originally Posted by your_shadow03 (Post 3470481)
man id

Code:

.....
.....
      -n, --name
              print a name instead of a number, for -ugG
.....
.....


Thanks for your info, but I think the option -n doesn't make sense here, you know, I want to get a username by its UID.

Andy

andy820303 03-10-2009 11:53 PM

Quote:

Originally Posted by rizwanrafique (Post 3470480)
Not sure about any such command but you can easily find it by doing:

Code:

grep "^user:" /etc/passwd|cut -f 3 -d ":"
Replace user with the username you want to lookup.

It's great, but I could not use it in my case, since I'm using those Linux commands from a windows system by the help of SFU(Service For Unix, a component provided by MS), so actually, I have no /etc/passwd in hands.

Thanks
Andy


All times are GMT -5. The time now is 08:28 PM.