-2

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

Mircea Vutcovici
  • 16,706
  • 4
  • 52
  • 80
hendry
  • 667
  • 2
  • 10
  • 23

2 Answers2

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.

Florin Asăvoaie
  • 6,932
  • 22
  • 35
Mircea Vutcovici
  • 16,706
  • 4
  • 52
  • 80
  • But that would be overkill because there are files in the directory that are being worked with. – hendry Dec 08 '15 at 05: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? – Mircea Vutcovici Dec 08 '15 at 05:38
  • I don't want a symlink to be type changed? – hendry Dec 08 '15 at 05: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.

user9517
  • 114,104
  • 20
  • 206
  • 289