LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-10-2009, 03:10 AM   #1
andy820303
LQ Newbie
 
Registered: Feb 2009
Location: Dalian, China
Posts: 12

Rep: Reputation: 0
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
 
Old 03-10-2009, 04:16 AM   #2
rizwanrafique
Member
 
Registered: Jul 2006
Distribution: Debian, Ubuntu, openSUSE, CentOS
Posts: 147

Rep: Reputation: 19
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.
 
Old 03-10-2009, 04:17 AM   #3
your_shadow03
Senior Member
 
Registered: Jun 2008
Location: Germany
Distribution: Slackware
Posts: 1,462
Blog Entries: 6

Rep: Reputation: 51
man id

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

Last edited by your_shadow03; 03-10-2009 at 04:18 AM.
 
Old 03-11-2009, 12:51 AM   #4
andy820303
LQ Newbie
 
Registered: Feb 2009
Location: Dalian, China
Posts: 12

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by your_shadow03 View Post
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
 
Old 03-11-2009, 12:53 AM   #5
andy820303
LQ Newbie
 
Registered: Feb 2009
Location: Dalian, China
Posts: 12

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by rizwanrafique View Post
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Unprivileged user uid gabsik Linux - Security 3 02-19-2009 09:25 AM
read uid of a last user dhanabalanb Programming 1 07-28-2007 04:32 AM
Getting uid and/or username of logged in user rjstephens Programming 5 09-23-2004 06:02 PM
inputing text in perl rob0t Programming 3 08-03-2004 11:29 PM
Changing User IDs (UID) totalcommand Linux - Newbie 5 06-06-2003 07:47 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:13 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration