# Sharing a subdirectory within home folder

## static_k

Hi,

I'm trying to share a subfolder within my home directory and allow them only access to that folder. Is this possible to grant access to this folder and not allow browsing of any other directories in my home folder?

Thanks.

----------

## rharris221a

i believe you can just change your permissions on the other directories, don't allow "read" permission and they won't be able to view them. 

of course you have to leave a "path" to the directory you want to share , for example if you want to allow someone to view a directory at /home/myhome/directory  , you have to allow "read" permission for /home and /home/myhome .

i think you could also just change permission on the directory you want to allow sharing and then use a link from somewhere outside your home directory. then they could only see the directory you linked to , provide the rest of your directories don't allow "read" permission,  though i'm at work right now and can't test how well that would work as i can't connect to my home computer from this one

----------

## static_k

Thanks for the reply.

I didn't want the user to see other files and folders in my home directory so I don't want to set read permission. I tried the link idea but that didn't seem to work either. I get permission denied.

These are the 2 users: kuser and cuser. The folder is in kuser's home directory and each user belongs to the 'users' group. The directory I'm looking to share is called 'Shared'

```

kuser@homepc /media/disk/laptop/home/kuser $ ls -l

-rw-r-----   1    kuser kuser    43520 Nov  2 14:32 5fifteen-10-30-09.doc

-rw-r-----   1    kuser kuser   115200 Jun 22 22:17 5fifteen-10-31-07.doc

-rw-r-----   1    kuser kuser    28672 Jun 22 22:17 5fifteen-10-31-08.doc

-rw-r-----   1    kuser kuser   116224 Jun 22 22:17 5fifteen-11-02-07.doc

-rw-r-----   1    kuser kuser    43008 Nov  6 15:36 5fifteen-11-06-09.doc

-rw-r-----   1    kuser kuser    28672 Jun 22 22:17 5fifteen-11-07-08.doc

drwxr-x--- 190 kuser users     73728 Nov 12 11:54 Shared

```

Then I created a directory higher up called 'Music' and put a symbolic link pointing to that Shared directory.

```

cuser@homepc /media/disk/Music $ ls -l

lrwxrwxrwx 1 kuser users   37 Nov 12 12:03 laptop_music -> /media/disk/laptop/home/kuser/Shared

cuser@homepc /media/disk/Music $ cd laptop_music 

bash: cd: laptop_music: Permission denied

cuser@homepc /media/disk/Music $

```

I'm confused   :Question: 

----------

## Hu

Read permission and search permission are separate rights.  It is possible for someone to be able to list what files are in a directory, but be unable to open the files due to lack of search permission on the directory.  Similarly, it is possible to have a directory which cannot be listed, but which can be traversed if you know what you want in it.  To help us help you debug this, please post the output of ls -ld on each of the directories from the shared directory out to /.

----------

## chaseguard

As stated above, you should be able to do this by making the other user(s) into a group (or allow the group users) the desired access to the directory you want.  Then ensure all the higher level directories up to home have the same access.  Then, set permissions on each remaining lower level directory (that you do not want others to see) the way you want -- individually.    

Another kind of crazy option might be to create a separate folder somewhere on / with the permissions you want and bind your special /home/you/directory to it in fstab.

----------

## static_k

Hi Guys,

I apologize for the delay in getting back but hopefully your still around to help out. Below is the ls -ld output:

```

kuser@homepc /media/disk/laptop/home/kuser/Shared $ ls -ld

drwxrwxr-x 196 kuser users 73728 Dec 30 09:55 .

kuser@homepc /media/disk/laptop/home/kuser/Shared $ cd ..

kuser@homepc /media/disk/laptop/home/kuser $ ls -ld

drwxr-x--- 147 kuser kuser 28672 Dec 30 09:55 .

kuser@homepc /media/disk/laptop/home/kuser $ cd ..

kuser@homepc /media/disk/laptop/home $ ls -ld

drwxrwxrwx 3 kuser kuser 4096 Jun 22  2009 .

kuser@homepc /media/disk/laptop/home $ cd ..

kuser@homepc /media/disk/laptop $ ls -ld

drwxr-xr-x 3 kuser kuser 4096 Jun 22  2009 .

kuser@homepc /media/disk/laptop $ cd ..

kuser@homepc /media/disk $ ls -ld

drwxrwxr-x 8 root users 4096 Dec 16 20:10 .

kuser@homepc /media/disk $ cd ..

kuser@homepc /media $ ls -ld

drwxrwxr-x 3 root users 4096 Dec 23 21:25 .

kuser@homepc /media $ cd ..

kuser@homepc / $ ls -ld

drwxr-xr-x 20 root root 4096 Mar  7  2009 .

```

Thanks again for any help.

----------

## Hu

.../home/kuser does not grant search permission to other.  You can allow users to explore Shared by chmod o+x kuser.

----------

## static_k

 *Hu wrote:*   

> .../home/kuser does not grant search permission to other.  You can allow users to explore Shared by chmod o+x kuser.

 

That did it! Thanks a lot.  :Very Happy: 

----------

