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?


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


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


drwxrwxr-x  site usergroup                                  /usr/local/test/
  • 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

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.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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