symbolic link to a folder whose parent directory does not have execute permission
want to make a soft link from one directory to another, and the directory I am trying to access I have read and executed. However, its parent directory I don’t have execute permission.
Is there a way to make a soft link to the directory I want without giving me execute access to the parent directory?
Here’s the code I used:
ln -s /home/dir1/dir2/desired_directory symbolic_link_name
The link just appears red on a gray background.
Although this is not possible for symbolic links, you can do it using mount –bind. Note that if the focus is on circumventing security, then this can be a very bad idea.
Your command is
mount --bind /home/dir1/dir2/desired_directory mount_dir
There are a couple of issues to be aware of:
- The target directory must exist before mount_dir (as with any mount point).
- Root access is required to execute mount commands
- Unless you add the corresponding line in /etc/fstab, the created “link” does not persist across restarts
- If the source directory contains mounted file systems, these will not be transferred to the destination. The mount point appears as an empty directory.
- Using mount –bind may be considered bad practice because most programs do not know that “link” is not a standard directory. For example, it allows creating loops in the directory tree, putting any tree parsing application (think “ls -R”) into a possible infinite loop.
- Can be dangerous when used in conjunction with recursive delete operations. See e.g. Yet another warning about mount –bind and rm -rf