Answer the question
In order to leave comments, you need to log in
How to prevent superuser from modifying a file?
Hello.
I am just starting to learn linux. Interested in how you can prohibit changing the file for root'a. For example, how is this possible:
[email protected]:~# ls -lh /etc/sysctl.conf
-rw-r--r-- 1 root root 19 Dec 27 17:16 /etc/sysctl.conf
[email protected]:~# > /etc/sysctl .conf
-bash: /etc/sysctl.conf: Permission denied
Answer the question
In order to leave comments, you need to log in
Offhand
1. Selinux
2. FS in RO.
But if a competent root, everything can get around :)
The file does not have execution rights (+x), bash tells you about this when you try to run it.
What is impossible here? -
a regular file (not a directory - d, and not some kind of link - l) rw-
the current user has the right to read (r) and write (w), but cannot execute the file (-) r--
users from the current group (root) have the right to read (r), but do not have write (-) and execute file (-) r--
all other users (read - World) have read (r), but do not have write (-) and file execute (- ) root root
the current user from the root group
The command
does not change the file, it executes it (after reading it) :)
PS Here you can read about the prohibition of editing files even by the root user. But the limitation is rather arbitrary.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question