Setting up a shared folder in Linux

3

I'm trying to set up a folder in my home directory that will be shared with another user, but I can't get it to work.

This is what I've done: I have tried two different ways using ACL's and chown/chgrp, etc.

I set up a group called sharedgroup and added both my user (john) and fred to it:

$ groups john
john wheel sharedgroup
$ groups fred
sharedgroup fred 
$ mkdir /home/john/shared
$ vim /home/john/shared/hello.txt #typed in some text, saved it
$ chown -R :sharedgroup shared
$ chmod -R o=-rwx shared
$ ls -l
drwxrwx--- 2 john sharedgroup 4096 Sep 9 21:14 shared
$ ls -l shared
-rw-rw-r-- 1 john sharedgroup 7 Sep 9 21:14 hello.txt

(Note: I also tried adding the s permission, but that didn't help.)

Then when I log out of the server and log back in as fred and try these commands they fail:

$ vim /home/john/shared/hello.txt #won't allow me to write; opens a blank file
$ cd /home/john/shared
-bash: cd: /home/john/cis: Permission Denied
$ ls /home/john/shared
-ls: /home/john/shared: Permission Denied
$ ls -lad /home/john/shared
-ls: /home/john/shared: Permission Denied
$ id fred
uid=500(fred) gid=502(sharedgroup) groups=502(sharedgroup),500(fred) 
context=user_u:system_r:unconfined_t

What am I doing wrong?

Chris

Posted 2012-09-10T02:13:59.487

Reputation: 33

1Can you post the output of id and ls -lad /home/john/shared when logged in as fred? That PERMISSION DENIED error does not look like a linux error message - is it cut and paste? – Paul – 2012-09-10T02:42:39.990

ok posted and changed to actual output – Chris – 2012-09-10T02:58:51.630

Answers

4

Does fred have access to /home/john ?

Without access to the parent, you can't access the subdirectory.

See https://unix.stackexchange.com/questions/13858/do-the-parent-directorys-permissions-matter-when-accessing-a-subdirectory

david25272

Posted 2012-09-10T02:13:59.487

Reputation: 377

interesting I ran chown -R :sharedgroup /home/john then tried again but it still gave me permission denied with fred? is that what you mean by giving him permission – Chris – 2012-09-10T03:01:06.807

Ah hah! I had to also run chmod g=rwx /home/john then it worked Thanks! – Chris – 2012-09-10T03:08:20.760

for clarification purposes to fix the problem I ran chown -R :sharedgroup /home/john; chmod g=rwx /home/john – Chris – 2012-09-10T03:12:37.323

fred (or sharedgroup, or everybody) will need execute permission on /home and /home/john. – david25272 – 2012-09-10T03:17:09.453