Q
Q
q2zoff2018-12-28 13:11:10
linux
q2zoff, 2018-12-28 13:11:10

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

3 answer(s)
S
Sergey Utkin, 2018-12-28
@DerNitro

Offhand
1. Selinux
2. FS in RO.
But if a competent root, everything can get around :)

R
Radjah, 2018-12-28
@Radjah

The file does not have execution rights (+x), bash tells you about this when you try to run it.

Y
Yurii Nekrasov, 2019-01-03
@driversti

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 rootthe 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 question

Ask a Question

731 491 924 answers to any question