Z
Z
Zimaell2020-02-06 09:59:08
linux
Zimaell, 2020-02-06 09:59:08

How to properly set file permissions?

It seems like such an elementary thing, but I can’t understand if I’m doing it right - the text for the sitemap is generated on the server and then this text is written to it, but with the rights somehow I think it’s not what I need, I set the rights 666 is written, I set 664 " failed to open stream: Permission denied", but if you set 666, then as I understand it, anyone can change it, right? And why at 664 writes that there are not enough rights, because

"user" - the owner of the file
"group" - one of the members of the group to which the owner belongs
"world" - "the rest of the world", that is, all other users

and that is, a green light is given for user and group ...

Answer the question

In order to leave comments, you need to log in

4 answer(s)
A
Alexey Ukolov, 2020-02-06
@Zimaell

You have a file created from one user, and php is executed from another, which is not even included in the group of the first.
Try to create a php file next to the sitemap, compare the owners and make sure.
The problem is solved simply - you need to change the owner of the file to the user under which php is running.

V
Valdemar Smorman, 2020-02-06
@smorman

sudo chmod 666 /directory/folder/file... (you can also 777, well, with all rights)
if on a folder, then:
sudo chmod -R 777 /directory/folder

S
SOTVM, 2020-02-06
@sotvm

directories 755
files 644
without special need, these rules should not be changed,
but for paranoids, you can tighten
them PS
only the owner of the file can change it
when the file is written by the server, then it has a different name and group (open and see the owner

K
Karpion, 2020-02-07
@Karpion

I will add to the above: it is necessary to set not only the rights, but also the owner and the group.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question