Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am adding a user using

useradd -d /home/testuser -m -g usergroup -s /bin/bash testuser

The group 'usergroup' already exists. This command runs fine and the user is created. However, when I try to use it to write to a folder that only has group write permission, it says permission denied. When I look in /etc/group , the user is not in the list of users that belong to 'usergroup'. Is there an extra step I am missing?

Update

forgot to mention that when I add the user to /etc/group, he has the correct access.

id:

uid=524(testuser) gid=524(usergroup) groups=524(usergroup)

ls:

drwxrwxr-x  site usergroup                                  /usr/local/test/
share|improve this question
1  
If your primary group is usergroup you needn't be listed for that group in /etc/group. Please post the output of id (when you are testuser) and the output of ls -ldZ /path/to/folder –  Mark Wagner Oct 22 '10 at 23:05
    
Show the permissions and ownership of the directory you're unable to write to. –  Dennis Williamson Oct 22 '10 at 23:53
    
Are you using ACLs? What does getfacl /usr/local/test/ say? –  Steven Monday Oct 23 '10 at 0:07
add comment

1 Answer

up vote 4 down vote accepted

To add a user to a group IN ADDITION to their "personal" group, you need to use the -G option. This is probably the option you want, otherwise that user's home directory will be

drwxr-xr-x 2 user usergroup

Unless, of course, you don't want the user to have any personal stuff at all. If you want the user to write files with the usergroup group when working on the shared directory, set the sgid bit on the directory (chmod g+s /usr/local/test/), this causes files created in that directory to always have the same group as the directory.

share|improve this answer
    
Using -G instead of -g worked, thanks. –  shipmaster Oct 23 '10 at 1:02
add comment

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.