V
V
Viktor Taran2018-11-06 12:43:39
linux
Viktor Taran, 2018-11-06 12:43:39

How to edit and create a file as root without changing the owner of the files in the folder?

The task is quite simple, but I would like full automation.
And so the essence of the problem
On the server, employees work as root
But each site has its own group and user
-линка /var/www/site.ru/web
-реальная /var/www/client1/web3/web
Respectively client1 and web3 group and user, respectively.

# ls -la
drwxr-xr-x 23 web3 client1 4096 Aug 9 00:18 web

The essence of the problem
Since employees work as root, the rights fly off and are set to root, periodically you have to do chown
As it turned out today, the guys threw a script that sets all the rights in the chown -R client1:web3 folder.
Actually, the question arose of how to automate this action completely
1. If we work as root
2. If /var/www/.../web or /var/www/client[0-9]{1,}/web
3. Take the owner and the folder's group - it's cunning...but it's mounted and has the correct permissions by default.
4. Set to all files, optional here, when editing a file, to the entire folder, etc., etc.
The main thing is that the owner of the files does not change

Answer the question

In order to leave comments, you need to log in

2 answer(s)
O
OnYourLips, 2018-11-06
@shambler81

The obvious solution is to take away the root of the law. Let them work from users of projects.

R
Radjah, 2018-11-06
@Radjah

Use sudo for example.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question