Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

My home directory's permissions allow only myself access to it. Is it possible to put a file inside my home directory with.. say.. full permissions, and create a symlink to it so other users can access that file alone inside my home folder? System is Ubuntu Karmic.

share|improve this question
add comment

2 Answers

It's possible, but not with symbolic links. It's called Hard links. Usage:

ln /home/you/the-file /some/public/folder/

A reference to the file "the-file" will be created in /some/public/folder/the-file.

Hard links points to the same inode (file, directory, ...). Symbolic links have their own inode, and will not work in chroots for example. Since hard links links to a inode instead of a path, it can only be used on the same filesystem.

Another way would be bind mounts. This will require root permissions for running the mount command and can only be used for directories. Usage:

sudo mount --bind /home/you/the-folder-to-be-shared/ /some/public/folder

/some/public/folder should be an existent folder. It does not have to be empty, although it's recommended because the contents will not be visible after mounting /home/you/the-folder-to-be-shared on /some/public/folder. If you decide to remove this shared folder from /some/public/folder, run:

sudo umount /some/public/folder
share|improve this answer
1  
Bear in mind the hard link needs to be on the same file system as the linked file, which may or may not be an issue if you have your own /home filesystem –  Sirex Jan 24 '11 at 15:54
    
Good point, added it. –  Lekensteyn Jan 24 '11 at 15:56
add comment

An easier way is to make a dir in your home directory, set it to whatever permission for the users you want to read to do so, then set your home dir to 701 permission.

With directories the read permission is needed to list the contents, execute to enter (as in to traverse, as done in the /path/to/dir part of the ls), and write to create files (when together with execute).

ls /home/[user] -- permission denied
ls /home/[user]/[shared dir] -- allowed

Anyone know of a down side to this? Please comment.

share|improve this answer
add comment

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.