I have a folder hierarchy parent_folder -> inner_folder -> innermost_folder The steps I followed are (as a sudo user):

  • created a symlink pointing to parent_folder
  • set the permissions of the symlink to 0400 => chmod -h 0400
  • set the owner (of symlink) to root => chown -h root

Now I switch to normal user, ran ls -l in the folder which has the symlink, it throws error :

Permission denied

Is this the expected behaviour?


A symlink basically is a special file containing the path to the symlink target. So if you restrict access to the symlink itself to root you prevent all other users from reading the content of the symlink, which results in a "permission denied" error when ls tries to read the symlink to identify the target.

To prevent ls from following the symlink (reading its content), use ls -P.

You can still remove the symlink (or actually any file not owned/accessible by yourself) as long as you have write access to the directory the symlink is in. A directory is basically an index, you can add/remove entries from it even without having access to the content of these entries.

  • my actual concern is why does the system let the user remove the symlink even if they do not have permissions? the normal user does have permissions on the folder where the symlink is but not on the symlink itself: lr-------- 1 root group 18 Nov 4 14:50 parent -- symlink PS: Sorry that my original question was unclear Nov 5 '19 at 22:02
  • @DeepaShenoy See updated answer. You may want to edit your question as well though, it doesn't say anything about removing symlinks.
    – nohillside
    Nov 6 '19 at 6:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .