两个用户的Unix写入权限?

use*_*743 3 unix permissions

我有一台开发机器,我在其中签出了 subvserions 项目,因此我的用户帐户具有这些文件的所有权权限。但是,它们是网站,有时apache用户(www-data)需要写入目录(临时文件,上传等)。

我对 Unix 权限不太熟悉,但是当我将所有权授予一个时,另一个就不能写了。我怎样才能得到它以便两者都可以写入目录?(我已将所有目录的权限更改为 755。)

Pyl*_*lsa 9

将它们都添加到一个组中,并为该组授予您希望它们都写入的目录的写入权限。

Create a new group:
    $ sudo groupadd groupname

Add users to the group:
    $ sudo usermod -a -G groupname username1
    $ sudo usermod -a -G groupname username2

Set the permissions as you want them to be for everyone else. 
(755 as it is now is probably unwise...)

Set the directory ownership to the group:
    $ sudo chgrp -R groupname /directory

Give the group write permission:
    $ sudo chmod -R g+w /directory
Run Code Online (Sandbox Code Playgroud)

如果您希望更多用户拥有写入权限,只需使用以下命令将他们添加到该组:

$ sudo usermod -a -G groupname username
Run Code Online (Sandbox Code Playgroud)