Adding Users Command line

Rick Stevens rstevens at vitalstream.com
Tue Oct 17 22:52:47 UTC 2006


On Tue, 2006-10-17 at 15:27 -0500, Bob McClure Jr wrote:
> On Tue, Oct 17, 2006 at 01:16:14PM -0700, Bret Stern wrote:
> > 
> > 
> > When adding users from the (command line)
> > 
> > useradd 
> > 
> > has an option -r which assigns a specific user id.
> 
> Nope, that tells it to assign a "system-level" user id number, usually
> less than 500 or 1000.  These are designed for pseudo users assigned
> to subsystems and processes like mysql, procmail, backup, bin, et al.
> 
> > Is it common to explicitly assign a user id?
> 
> Only if you want to make it the same as on another system or to force
> a duplicated UID.

Or if you relegate ranges of UIDs to specific types of users.


> > What happens if I don't specifically assign a user id?
> 
> It takes the next available UID in the desired range.  That's usually
> figured by taking the highest occupied UID in the range and adding
> one.

The values used are given in /etc/login.defs.  By default, RH/FC use
user and group IDs beginning at 500 and ending at 60,000.

> > I'm assuming two users cannot have the same user id,
> > so..how would you know the user id's of all your users?

Well, all files use the UID and GID _numbers_, not names.  You could
have two users, "barney" and "fred" that both have UID 500.  They both
own the file.  When you do an "ls -l", the FIRST name in the /etc/passwd
file with that UID will be shown as the owner.

Remember that the the usernames are only important for login.  File
ownership, permissions, ACLs and the lot are determined by UID and GID
numbers, not the names associated with them.

> You don't need to, but if you must, look at the third field (delimited
> by ':') in /etc/passwd.  Unless you have some good reason to specify a
> UID, just let the system assign one.

If you want to see the user names and their UIDs, as root:

	# cut -d":" -f1,3 /etc/passwd

But as Bobcat says, you really don't need to do this.  Let the system
sort it out.  It's much less likely to make a boo-boo.

----------------------------------------------------------------------
- Rick Stevens, Senior Systems Engineer     rstevens at vitalstream.com -
- VitalStream, Inc.                       http://www.vitalstream.com -
-                                                                    -
-     Veni, Vidi, VISA:  I came, I saw, I did a little shopping.     -
----------------------------------------------------------------------




More information about the Redhat-install-list mailing list