A
A
Alexander2019-04-06 13:53:38
linux
Alexander, 2019-04-06 13:53:38

How to create folders and files with pre-set owner and group?

There is a domain folder /var/www/mysite.ru with permissions 775 . As an owner ( user1) a user who connects via SFTP and accordingly can change the contents of files, create folders \ files, delete them, etc. And as a group - web- this group includes users of the necessary services - a web server, PHP-FPM, etc.

[[email protected] www] ls -l mysite.ru
drwxrwxr-x 4 user1 web   4096 апр  6 13:00 public

When creating a new folder or a new file as user1 , user1 is set as the default group . It is impossible to change the group on behalf of the same user1, because it does not have admin rights.
[[email protected] www]$ touch mysite.ru/myfile && ls -l mysite.ru
итого 4
-rwxrwxr-x 1 user1 user1    0 апр  6 13:54 myfile
drwxrwxr-x 4 user1 web   4096 апр  6 13:00 public

It is necessary that when creating folders and files on behalf of each of the users (user1, user2, ...), the user who created the file / folder is set as the default owner, and web as the group . But at the same time, there is a nuance - it is impossible to assign each of these users the web group as a standard one, because this group has read-write permissions in service directories (logs, for example), which should not be writable by users.
How can this be implemented?

Answer the question

In order to leave comments, you need to log in

[[+comments_count]] answer(s)
V
vreitech, 2019-04-06
@zkelo

setfacl -m d:g:web:rwx /var/www/mysite.ru

R
Ronald McDonald, 2019-04-06
@Zoominger

mkdir -m777 <foldername>
For example.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question