-2

I cannot seem to work out how to protect a symbolic symlink from being deleted/removed or overwritten. Any ideas?

1
  • chmod ugo -w & chattr +i
    – hendry
    Dec 8, 2015 at 5:01

2 Answers 2

2

You need to deny access to the directory where symlink resides.

EDIT:

When you move/rename/delete a file in Unix based operating systems, you are modifying the directory in which they are located, not the files themselves. So permissions on the file don't matter at all.

3
  • But that would be overkill because there are files in the directory that are being worked with.
    – hendry
    Dec 8, 2015 at 5:26
  • When you delete a symlink, is the same as you delete a normal file. The only permission checked are on the folder. You can limit access to the folder with a SELinux policy, or other mechanisms. But the main question is what is the real problem you are trying to solve? Dec 8, 2015 at 5:38
  • I don't want a symlink to be type changed?
    – hendry
    Dec 8, 2015 at 5:46
0

You cannot change the permissions (or attributes) of a link, trying to do so is meaningless. From the chmod man page

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. However, for each symbolic link listed on the command line, chmod changes the permissions of the pointed-to file.

You must log in to answer this question.

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