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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
05-24-2012, 09:21 AM
|
#1
|
Member
Registered: May 2011
Posts: 194
Rep:
|
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!
|
|
|
05-24-2012, 09:34 AM
|
#2
|
Moderator
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417
|
/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 09:35 AM.
|
|
|
05-24-2012, 09:45 AM
|
#3
|
Member
Registered: Sep 2008
Location: The Netherlands
Distribution: Slackware64 current
Posts: 594
Rep:
|
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.
|
05-24-2012, 09:49 AM
|
#4
|
Member
Registered: Sep 2008
Location: The Netherlands
Distribution: Slackware64 current
Posts: 594
Rep:
|
Quote:
getent passwd | cut -d: -f4 | sort -n | tail -n1
|
-f4 needs to be -f3
|
|
1 members found this post helpful.
|
05-24-2012, 09:51 AM
|
#5
|
Moderator
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417
|
Quote:
Originally Posted by whizje
-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.
|
05-24-2012, 10:00 AM
|
#6
|
Member
Registered: May 2011
Posts: 194
Original Poster
Rep:
|
Thanks everyone for quick and exact solution!!!
|
|
|
All times are GMT -5. The time now is 10:11 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|