E
E
elisey4742016-09-14 22:47:19
linux
elisey474, 2016-09-14 22:47:19

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:
6321e0b005e34b679ffa328a7d2e26d0.jpg

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Y
Yuri Chudnovsky, 2016-09-15
@elisey474

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.

L
Lynn "Coffee Man", 2016-09-14
@Lynn

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 question

Ask a Question

731 491 924 answers to any question