W
W
Warington2022-01-22 17:17:03
linux
Warington, 2022-01-22 17:17:03

How to make files and folders with a certain group created under any user?

Conventionally, there is a folder /var/www/html , in which several users work via ssh and each of them under their own user.

There is a situation when a user creates a file and it is not available to others for editing.
You have to change the group to one that has all these users.

Ideally, it would be desirable that when creating a folder / file in /var/www/html it was immediately created with this group. How to do it?

I read about sticky bit, but as far as I understand, for this you have to change the main user group, this is not suitable.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
Michael, 2022-01-22
@Warington

Suppose all these users are members of the editors group
1. Set the editors group to the /var/www/html directory
2. Set the SGID bit on this directory.
As far as I understand (I don’t have Linux at hand right now, I can’t check it), the files in this directory will be created as belonging to the same group as the directory itself.

S
SOTVM, 2022-01-22
@sotvm

it just depends on the user.
as he wants = so it will be
and root = this is the highest level in the hierarchy = this is the God of the system :))
I see that we are talking about the server,
so configure it,
but not a single sane administrator will give you such rights by default / default

S
shurshur, 2022-01-22
@shurshur

You can use SGID (written above).
You can use the default ACL, something like this:

setfacl -m g:developers:rwx -m d:g:developers:rwx -R /var/www/html
setfacl -m u:www-data:rx -m d:u:www-data:rx -R /var/www/html
setfacl -m u:www-data:rwx -m d:u:www-data:rwx -R /var/www/html/uploads

Then for the specified users and groups, accesses from the ACL will be applied, and for new files/directories - from the default ACL.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question