在创建文件时更改linux用户的默认所有权? [英] Change linux user default ownership on file creation?

查看:269
本文介绍了在创建文件时更改linux用户的默认所有权?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个在用户部署下运行的部署scipt,但是它似乎是很容易找到的东西,但是Googling带来了许多无关的任务。我的网络服务器运行为nginx我希望Web服务器能够写入部署的文件。



Ive添加了nginx到部署用户组,我相信我可以轻松地使用所有权nginx:deploy的部署用户编写文件,但默认情况下,它会将文件创建为deploy:deploy,这是nginx不会写的。



有没有改变用户,以便默认情况下创建文件为nginx:deploy来解决这个问题?

解决方案

install 命令具有控制所创建文件的所有者和组的选项。但一般来说,只有 root 可以创建一个不同用户的文件。也许您可以配置 sudoers 部署用户运行 sudo 作为 nginx 用户。


Seems like something which should be easy to find but Googling brings up lots of unrelated tasks.

I have a deploy scipt which runs under the user "deploy" but my web server runs as "nginx" I want the web server to be able to write to the deployed files.

Ive added nginx to the deploy user group and I believe I can write files with deploy user with the ownership "nginx:deploy" easily now but by default it creates files as "deploy:deploy" obviously which nginx won't write too.

Is there anyway to change the user so that by default creates files as "nginx:deploy" to solve this problem?

解决方案

The install command has options to control the owner and group of the files it creates. But in general, only root can create files as a different user. Maybe you can configure sudoers to let the deploy user run the commands it needs with sudo as the nginx user.

这篇关于在创建文件时更改linux用户的默认所有权?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆