2

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/
3
  • 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 Oct 22, 2010 at 23:05
  • Show the permissions and ownership of the directory you're unable to write to. Oct 22, 2010 at 23:53
  • Are you using ACLs? What does getfacl /usr/local/test/ say? Oct 23, 2010 at 0:07

1 Answer 1

4

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.

1
  • Using -G instead of -g worked, thanks.
    – shipmaster
    Oct 23, 2010 at 1:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .