Answer the question
In order to leave comments, you need to log in
Why linux file permissions don't work?
Actually there is a file, the rights are: -rw-r--r-- 1 root root
I try to enter as a normal user: nano file
nano warns that there are no write rights, I
try to enter: mv file file.2 and it is renamed. How so? How to prevent renaming? Why do not plow the rights -rw-r--r-- 1 root root?
I also try to enter: rm file , rm asks whether to delete the file because it is write-protected, I answer yes and the file is deleted. And how to forbid it and why the rights -rw-r--r-- 1 root root do not plow?
Screenshot:
Answer the question
In order to leave comments, you need to log in
When there is no write access to a file, it cannot be changed. But you can delete it if you have write permissions to the file - the directory in which this file is registered. And vice versa, if there are write permissions to the file, then it can be changed, but it will not be possible to delete it if there are no write permissions to the directory in which it lies. Yes, a directory is almost like a text file, by "editing" which you can create or delete files, if you have permission to do so. So if you want the file not only not to be changed, but also deleted - the rights must be set not only on the file itself, but also on the directory where it lies.
Because moving (renaming) and deleting a file is not a change to the file, but to the directory in which it lies.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question