[[+content_image]]
V
V
Vadim Ushakov2021-02-26 13:34:55
linux
Vadim Ushakov, 2021-02-26 13:34:55

Linux administration, no access to file?

[[email protected] nightmare]$ ls
partial.php  test.txt
[[email protected] nightmare]$ ls -la
total 8
drwxr-xr-x 2 apache     apache       41 Feb 26 13:26 .
drwxr-xr-x 5 root       root         53 Feb 26 12:38 ..
-rw-rw-r-- 1 nightmare0 nightmare0 1753 Feb 26 13:06 partial.php
-rw-r--r-- 1 apache     apache       13 Feb 26 13:26 test.txt
[[email protected] nightmare]$ groups
nightmare0 apache
[[email protected] nightmare]$ rm test.txt
rm: remove write-protected regular file ‘test.txt’? y
rm: cannot remove ‘test.txt’: Permission denied
[[email protected] nightmare]$


Why is that? The test.txt file has the apache group as does the nightmare0 user , but nightmare0 cannot delete the file.

Answer the question

In order to leave comments, you need to log in

[[+comments_count]] answer(s)
A
Adamos, 2021-02-26
@Adamos

In the answers, they correctly sent me to learn Linux rights.
But they forgot to note that deleting a file is not an operation on the file, but on the folder in which it lies. You need write access to it to create or delete files.
Therefore, file permissions do not play here at all - -rw-r--r--/apache/apache.
And the folder permissions decide: drwxr-xr-x/apache/apache.
In which, however, the user, by belonging to the apache group, has the same access - read only.

K
ky0, 2021-02-26
@ky0

The test.txt file has the apache group as does the nightmare0 user, but nightmare0 cannot delete the file.

It is not enough to have a group - you also need to allow the group to do something. Read more about the Linux permissions system, well.

S
Saboteur, 2021-02-26
@saboteur_kiev

drwxr-xr-x 2 apache apache 41 Feb 26 13:26 .
the rights of the apache rx group, that is, you cannot edit the directory.
Deleting a file is changing the directory.
You need to either be an apache / root user, or add rwxrwxr-x permissions to the folder

Z
Zzzz9, 2021-02-26
@Zzzz9

And what is wrong? Root and owner rw group read others read.

G
galaxy, 2021-02-26
@galaxy

Well, the key point: to delete a file, you need to have write permissions to its parent directory

drwxr-xr-x 2 apache     apache       41 Feb 26 13:26 .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question