0

I want to grant a user (username: eddie) access to all directories (with mod 770) shared by root (myself). I do it this way:

groups root
(here comes a list of groups in which root user is)

usermod -a -G group1 eddie
usermod -a -G group2 eddie
usermod -a -G group3 eddie
...

All the 'group1', 'group2', 'group3' are seen in the group list of root user.

However, after adding 'eddie' to all groups above (including group 'root'), he still can not write to directories shared by root user.

Did I do it wrongly?

6
  • 1
    Have you logout and relogin after add paul to the different groups?
    – Just1602
    Nov 10, 2013 at 1:36
  • hm, it's server, i dont want to reboot, anyway i'll try rebooting and see how
    – jondinham
    Nov 10, 2013 at 1:56
  • 1
    @Paul, you don't need to reboot a Linux server for perms to take effect. (You don't even need to log off and log back in again, its immediate)
    – davidgo
    Nov 10, 2013 at 6:05
  • 1
    I'm unsure from your question what you are trying to do, hence I have not put this in as an answer, but might you be looking for usermod -a -G root paul (To add Paul to the "root" group).
    – davidgo
    Nov 10, 2013 at 6:09
  • 2
    @nitro2k01 answer is good - changing the owner of the directory to eddie would be a better move - security wise. With the added information I do suspect my answer/comment is the command you were looking for - but, of-course, its not generally a good idea as it could give eddie access to more stuff then envisioned.
    – davidgo
    Nov 10, 2013 at 6:39

1 Answer 1

3

The owner of a file consists of two fields, one for the user and one for the group. If you do ls -l you can see the user as well as the group in the output. The group field in the file mode controls access for users in the group that owns a particular file.

It's irrelevant which groups root are in for your problem. Only the owner field for the file you want to give access to, and the other user's group memberships matter. If a file is owned by root:somothergroup and has mode 770, paul can only access that file if paul is in somothergroup.

If you want to share specific files, I'd suggest creating a group that you add eddie to and, and change the ownership of the files to that group. (e.g. chgrp -R somegroup somedirectory to recursively change the ownership of all files in that directory.)

Also, somewhat unrelated, I'd strongly discourage you from always running as root. It's generally better to use a less privileged user account for daily tasks and using sudo or su to elevate your privileges.

1
  • thank you, creating a new group for sharing is a good solution :)
    – jondinham
    Nov 10, 2013 at 6:56

You must log in to answer this question.

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