I have a directory containing a load of files and would like to access and using it as user, via a Softlink in the /opt directory, but keeping it in the /root directory:

root@computer:~# ll myDirectory_v11
root@computer:~# drwxr-xr-x  6 root root 4096 Jun 25 12:45  myDirectory_v11

Now I create a Softlink:

root@computer:~# ln -s /root/myDirectory_v11 /opt/myDirectory

To gain access and run software inside I change the owner, the like:

root@computer:~# chown -R myUser:myUser /opt/myDirectory

This returns no error and listing it inside the /opt confirms, that all went well. The owner changed correctly.

After logging out from root and trying to change into the /opt/myDirectory, I receive a bash: cd: /opt/myDirectory: Keine Berechtigung.

In Centos this was never an issue. How to make it accessible for the myUser?

I tried a lot of things, e.g. using -hR flag for prohibition of dereferencing or tried sysctl -w fs.protected_symlinks=0 to no avail. Has it something to do with some sticky-bit? If so, how to overcome the problem?

  • Likely because /root doesn't have execute permission for anyone except root – steeldriver Jun 25 '18 at 11:47
  • Thx. But if root gives access to one folder for one user, why isn't it possible to access it for the user? How to allow the user to use the folder and contents? – Semo Jun 25 '18 at 11:49
  • 1
    Because changing ownership on the sym-link don't change ownership on the file/directory the sym-link points to. – Soren A Jun 25 '18 at 12:37

As mentioned in the comments, the /root is missing the execute permission. If the upper folders do not allow the execution, you cannot look inside the sub-folders (even if you have permissions for this folders)

So add execute permission to the root folder with:

$ sudo chmod a+X /root

And it will work.

Word of advice, don’t store anything in the /root folder! There is no good reason for it. It is the home of the root user and should not be used for anything else. So after you tested that it works, remove the permission with sudo chmod go-X /root/

  • This. And chown -Rwill not follow symlinks. – RoVo Jun 25 '18 at 12:58
  • Accepted. Where would you store software? I created a symlink to avoid specific version numbers in directory names and afterwards to be forced to reconfigure depending stuff over and over again. So my idea was to simply bending the file pointer... ;-) – Semo Jun 25 '18 at 13:16
  • 1
    /usr/local/… is the usual place, where you store custom modifications. Use the bin for executables, lib, var, and share as used in the default /usr/. If you need or want to store everything in one folder, then /opt is a good place. – Simon Sudler Jun 25 '18 at 13:42
  • @SimonSudler Tried, worked, removed permissions. Moved package away from root and stuffed into /usr/local. Thank you very much for your assistance! – Semo Jun 26 '18 at 4:59

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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