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 have a development machine where I have subvserions projects checked out, so my user account has ownership permissions for those files. However, they are websites, and sometimes the apache user (www-data) needs to write to the directory (temporary files, uploads, etc.).

I'm not so familiar with Unix permissions, but when I give ownership to one, the other can't write. How can I get it so that both can write to the directories? (I've changed permissions to 755 for all the dirs.)

share|improve this question
add comment

1 Answer

up vote 8 down vote accepted

Add them both to a group, and give that group writing permissions for the directory you want them both to write to.

Create a new group:
    $ sudo groupadd groupname

Add users to the group:
    $ sudo usermod -a -G groupname username1
    $ sudo usermod -a -G groupname username2

Set the permissions as you want them to be for everyone else. 
(755 as it is now is probably unwise...)

Set the directory ownership to the group:
    $ sudo chgrp -R groupname /directory

Give the group write permission:
    $ sudo chmod -R g+w /directory

If you want more users to have write access, just add them to that group using:

$ sudo usermod -a -G groupname username
share|improve this answer
    
@user13743 Try it now, forgot the -a flag! Updated my answer. –  BloodPhilia Aug 10 '10 at 18:50
    
Awesome! But group_name username seems to be backwards on my system; I had to user 'sudo adduser -a www-data web-directory-writers' –  user13743 Aug 10 '10 at 18:52
    
@user13743 No! Then you added a user web-directory-writers to the group www-data! use like this: sudo useradd -a -G groupname username1 Don't forget the -G flag! What error do you get if you do it like that? –  BloodPhilia Aug 10 '10 at 18:54
    
>sudo adduser -a web-directory-writers www-data adduser: The user 'web-directory-writers' does not exist. >sudo adduser -a www-data web-directory-writers The user 'www-data' is already a member of 'web-directory-writers'.` –  user13743 Aug 10 '10 at 19:08
    
@user13743 You're forgetting the -G flag! sudo adduser -a **-G** web-directory-writers www-data –  BloodPhilia Aug 10 '10 at 19:11
show 7 more comments

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.