How to make a file editable by two different users in different groups?

Rather than modify permissions on the directory, it might be easier to put the user john into the www group. Users can be in multiple groups. Use either usermod, edit the /etc/group file, or if you have a GUI on your linux machine use the graphical user manager program (might be called different names based upon distro and desktop environment). The easiest method is probably to open a command prompt, and type in:

sudo usermod -G www -a john

It'll ask for your account password, and once you enter it, the user john will be have group level access to the /home/www directory.

This is assuming the group www already has read/write/execute access to the /home/www directory If that group doesn't have that level of access then use chgrp www /home/www and chmod g+rwx /home/www to take care of that.

note: if you are currently logged in as 'john', you may need to log out and back in for your permissions to update.


You can't. But you may be able to set an ACL for it.

setfacl -m g:john:rwx /home/www

Try creating new group www-and-john, then

chown -R www:www-and-john /home/www/

chmod -R g+w .

and in the end add both users to group www-and-john.