1

Say I want to create a symlink for a folder /media/drive/here (owned by a group) to a folder /home/pepe/private/here
Do all the intermediate folders need to have the x bit on?

What does the computer do when from /media/drive I execute cd here? Does it internally just cd /home/pepe/private/here? (I had to set the x bit in this situation to every intermediate folder, so that other users could access just my private folder here, but still not sure if this is correct, I thought only permissions on /home/pepe/private/here matters, not their parents folders)

  • 1
    basicly yes, you'll have to chmod +x all the hirrarcy to allow OTHERS to access the folder. Another why around this is to use bind mount – Rabin Jan 3 '17 at 21:20
0

To complement @Rabin's comment, you can confirm this by stat'ing root path:

# stat /
  File: '/'
  Size: 4096        Blocks: 8          IO Block: 4096   directory
Device: fe01h/65025d    Inode: 2           Links: 23
Access: (0755/drwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2017-01-03 11:51:24.202486304 +0000
Modify: 2016-06-20 16:31:24.210935643 +0100
Change: 2016-06-20 16:31:24.210935643 +0100
 Birth: -

If root didn't have o+x bit set, you would not be able to access your home directory as a regular user.

Symbolic links are basically used to keep things simple. For instance in most systems /lib and /lib64 point to exact same location, otherwise those would be copies of the same directory.

Also note the excerpt from man chmod:

chmod never changes the permissions of symbolic links; the chmod system call cannot change their permissions. This is not a problem since the permissions of symbolic links are never used.

Hence you cannot change the privileges of the symlinks and your user must be privileged to access all the resources which symilinks are traversing.

  • But then, what is the purpose of a symbolic link? Just to be able to type less to use a directory? I thought it could also be used to give access to a dirextory that otherwise wouldn't be accesible by certains users.. – dami Jan 4 '17 at 3:57
  • @dami: you can use mount --bind src dest instead. This will do what you want. – marlar Mar 16 '18 at 8:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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