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.

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?

share|improve this question
1  
Have you logout and relogin after add paul to the different groups? –  Just1602 Nov 10 '13 at 1:36
    
hm, it's server, i dont want to reboot, anyway i'll try rebooting and see how –  Jon Dinham Nov 10 '13 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 '13 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 '13 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 '13 at 6:39

1 Answer 1

up vote 3 down vote accepted

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.

share|improve this answer
    
thank you, creating a new group for sharing is a good solution :) –  Jon Dinham Nov 10 '13 at 6:56

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.