Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

New user is not taking system default Group ID. System default group id for new user is 100. Whenever i create a new user, GID as well as UID increments by 1. I can understand UID but GID should be 100 for every new user. What is the possible reason? I am using Amazon linux AMI on EC2.

# adduser -D
GROUP=100
HOME=/home
INACTIVE=-1
EXPIRE=
SHELL=/bin/bash
SKEL=/etc/skel
CREATE_MAIL_SPOOL=yes

# useradd -m testuser
# useradd -m testuser2

# cat /etc/passwd
testuser:x:501:503::/home/testuser:/bin/bash
testuser2:x:502:504::/home/testuser2:/bin/bash
share|improve this question
1  
I'm not sure about AMI, but on some OSes, adduser is actually a separate Perl wrapper script for useradd. Try using adduser instead when actually adding the user to see if that has any effect. –  Garrett Dec 17 '11 at 7:19
    
i tried adduser also, but unfortunately same result. –  P K Dec 17 '11 at 7:25
    
If your system's adduser is a Perl script and not a symlink to useradd, check /etc/adduser.conf and ensure that FIRST_GID is set appropriately. AMI may use GROUP as an alias of that, but the Ubuntu box I'm looking at now has no such definition. –  Garrett Dec 17 '11 at 7:40
    
i don't see any .conf file related to adduser in /etc –  P K Dec 17 '11 at 7:51

1 Answer 1

up vote 2 down vote accepted

Your system is configured to use user groups – to create a new group for each user, with the same name as the username. For example, your user testuser2(502) will have the primary group testuser2(504).

The configuration file for useradd is /etc/login.defs, and this setting is controlled by the USERGROUPS_ENAB statement. You can also temporarily change this behavior by using the options -U/--user-group and -N/--no-user-group.

Remember that useradd and adduser are separate programs; the defaults set in adduser do not necessarily affect the simpler useradd.

share|improve this answer
    
But USERGROUPS_ENAB says "This enables userdel to remove user groups if no members exist". Is related to addition of user? –  P K Dec 18 '11 at 14:17
    
@Praveen: Yes, see manual page of useradd, under -N and -U options. –  grawity Dec 18 '11 at 18:45
    
thanks.......... –  P K Dec 18 '11 at 18:48

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.