I cannot seem to work out how to protect a symbolic symlink from being deleted/removed or overwritten. Any ideas?
Asked
Active
Viewed 6,117 times
-2
-
chmod ugo -w & chattr +i – hendry Dec 08 '15 at 05:01
2 Answers
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.
![](../../users/profiles/214885.webp)
Florin Asăvoaie
- 6,932
- 22
- 35
![](../../users/profiles/30946.webp)
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
-
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.
![](../../users/profiles/9517.webp)
user9517
- 114,104
- 20
- 206
- 289