Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

On Ubuntu, I want user1 to be able to read/write/execute/delete all files/folders of user2

I have placed them under the same group but that doesn't seem to do it,

What is the correct way of approaching this?


share|improve this question
up vote 1 down vote accepted

You need to assign the group they are both in to all files of user 2.

 chgrp usergroup somefile

Then you need the group permissions to have rwx so:

chmod g+rwx somefile

Where somefile is a file of user2

share|improve this answer
user1 and user2 are under group "g1", and i have changed the group of all files to g1. the owner of the files is user1, and the group is g1. with these settings, user2 is not allowed to delete the files. – Jim Sep 4 '10 at 23:17
Works, just had to use the chmod g+rwx, thanks! – Jim Sep 4 '10 at 23:20
No problem, glad it worked for you :) – Joshua Enfield Sep 4 '10 at 23:20
Note that making all of user1's file group-writable will prevent logins to the user1 through ssh with keys. You should make at least ~, ~/.ssh and ~/.ssh/authorized_keys non-group-writable. – Gilles Sep 4 '10 at 23:37

Putting both users in the same group is not enough: by default, files are not group-writable unless explictly made so (with chmod g+w). To change the default permissions for most newly created files, add the line umask 002 to ~user1/.profile. Also many programs restrict files that should normally be kept private (password files, mailboxes, ...) to be readable only by the user; the umask has no effect on this.

A way that will work most of the time is to use access control lists. First, make sure that the filesystem containing user2's home directory is mounted with the acl option (it's off by default on Ubuntu 10.04). Install the acl package. Then run the following commands (warning, typed directly into the browser) to give user1 all accesses to the files in user2's home directory and give this access by default to newly created files:

setfacl -m user:user1:rwx -R ~user2
setfacl -d -m user:user1:rwx -R ~user2

If user2 keeps files outside his home directory, apply this command to the other directories as well.

Finally, giving user1 this direct access may not be the best method to solve the underlying problem. It may be more reasonable to give user2 access only to the files that actually need to be shared (either using a common group or using ACLs). Consider also giving user2 the permission to run programs as user1 through sudo (run visudo and add the line user1 ALL = (user2) ALL).

share|improve this answer
seems se dont have any restrictions regarding to put both users in the same group. In this case ACL is to much ;) – Robert Sep 4 '10 at 23:57

User1 must be a member of the group that is assigned to the group that has rwx (7, as in whatever for the user and other permission, but a 7 listed for the group permission).

Does this help?

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.