LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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 05-24-2012, 08:21 AM   #1
linuxandtsm
Member
 
Registered: May 2011
Posts: 194

Rep: Reputation: Disabled
user id number


Hi all,

how to find what is the max id number that is been assigned to a user in linux ?
/etc/passwd file might have it but not sure how to find it if it has too many entries in it ?

and also what is the range of id's can be used in linux ?


Thanks in advance!
 
Old 05-24-2012, 08:34 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
/etc/login.defs defines the max and min uids and gids. There is no formal way to find out the current max UID, as it's not an interesting thing to want to know. you can easily spit the output of "getent passwd" through cut and the likes though.


getent passwd | cut -d: -f4 | sort -n | tail -n1

Last edited by acid_kewpie; 05-24-2012 at 08:35 AM.
 
Old 05-24-2012, 08:45 AM   #3
whizje
Member
 
Registered: Sep 2008
Location: The Netherlands
Distribution: Slackware64 current
Posts: 594

Rep: Reputation: 141Reputation: 141
Code:
awk -F":" 'END{ print "username: " $1 "\t\tuid:" $3 }' /etc/passwd
Assumed the last entry has the highest uid. Else you have to search the passwd file for the highest uid.
 
1 members found this post helpful.
Old 05-24-2012, 08:49 AM   #4
whizje
Member
 
Registered: Sep 2008
Location: The Netherlands
Distribution: Slackware64 current
Posts: 594

Rep: Reputation: 141Reputation: 141
Quote:
getent passwd | cut -d: -f4 | sort -n | tail -n1
-f4 needs to be -f3
 
1 members found this post helpful.
Old 05-24-2012, 08:51 AM   #5
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
Quote:
Originally Posted by whizje View Post
-f4 needs to be -f3
Doh yes, I tested that against an F5 BigIP appliance which makes all users uid 0 so I got confused!
 
1 members found this post helpful.
Old 05-24-2012, 09:00 AM   #6
linuxandtsm
Member
 
Registered: May 2011
Posts: 194

Original Poster
Rep: Reputation: Disabled
Thanks everyone for quick and exact solution!!!
 
  


Reply



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
What does it mean when the user is a number? pgflrob Linux - Newbie 4 03-11-2012 10:09 AM
New user - number of posts before url Jeebizz LQ Suggestions & Feedback 21 09-21-2011 11:22 AM
Identify and explain the major number, minor number, and revision number in Linux... turbomen Linux - Newbie 1 11-16-2010 02:48 AM
Number of current sessions for user neel_learning_linux Linux - Newbie 5 05-13-2009 03:14 PM
user shows up as a number in ps aux chibi Linux - General 3 05-04-2005 08:40 AM

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

All times are GMT -5. The time now is 09:46 AM.

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
Open Source Consulting | Domain Registration