Share a directory



Hi there,

I have two users and I would like to share a root directory called projects between them:

drwxrwsrwx 2 root apologeci 4096 2014-01-14 10:50 projects
id user1
uid=1002(user1) gid=1002(user1) grupy=1002(user1),1003(apologeci)

id user2
uid=1003(user2) gid=1004(user2) grupy=1004(user2),1003(apologeci)

cd /home/user1
ln -s /root/projects projects

cd /home/user2
ln -s /root/projects projects

su user1
cd /home/user1/projects

access denied

What am I doing wrong ?

This appears to be a permission's error. Regular users should not be able to access Root's files like that.

Instead, what if you made a new folder -

user1@COMPUTER:~$ sudo mkdir /project/
user1@COMPUTER:~$ sudo chmod 777 /project/ #if ALL users may use the directory

If you only want these two users to access the file, then make a user-group only containing these two users and then give that group permissions to access and use the directory.
You may have messed up permissions on the links you created. Check them...
1. It already is 777 or drwxrwsrwx
2. Also both users are in the group 1003(apologeci)
3. lrwxrwxrwx 1 user1 user1 14 2014-01-14 11:46 projects -> /root/projects
4. drwxrwsrwx 2 user1 apologeci 4096 2014-01-14 10:50 projects

Comment to 4: Even if I set user1 as the owner of /root/projects, then:
su user1
cd /home/user1/projects tells me: can't cd to projects

Strange right ?
What else should I do ?
Usually users can't do anything in /root as that is typically reserved for root. Please be aware that setting permissions to 777 is a dangerous and non-secure idea.

Here is what I would suggest:

Make a location for the users to share:

mkdir /project
chown root:apologeci /project
chown 774 /project
chmod g+s /project

Now you should be able to create files in the location as both users, and edit files in the location as well. You will notice that the group now stays consistent across all the files that are in the location now.

Members online