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?
Thanks,
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
~
, ~/.ssh
and ~/.ssh/authorized_keys
non-group-writable.
Sep 4, 2010 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
).
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?