Use symlink to provide access to a specific file under a restricted directory
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
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.