Ben*_*ann 101 linux permissions file-permissions
我想在我所属的工作人员组所拥有的目录中创建一个文件.为什么我不这样做?
bmccann@bmccann-htpc:~$ ls -l /usr/local/lib/R/
total 4
drwxrwsr-x 2 root staff 4096 2010-07-31 16:21 site-library
bmccann@bmccann-htpc:~$ id -nG bmccann
bmccann adm dialout cdrom plugdev staff lpadmin admin sambashare
bmccann@bmccann-htpc:~$ touch /usr/local/lib/R/site-library/tmp
touch: cannot touch `/usr/local/lib/R/site-library/tmp': Permission denied
Run Code Online (Sandbox Code Playgroud)
Ada*_*onR 192
您是否在进行组更改后注销并重新登录?请参阅:
涉及触摸权限失败的超级用户答案
Eri*_*ski 14
为什么Linux用户不能编辑他所属的组中的文件?
我正在使用Ubuntu 12.04并遇到同样的问题,即用户无法写入允许组访问的文件.例如:
whoami //I am user el
el
touch /foobar/test_file //make a new file
sudo chown root:www-data /foobar/test_file //User=root group=www-data
sudo chmod 474 /foobar/test_file //owner and others get only read,
//group gets rwx
sudo groupadd www-data //create group called www-data
groups //take a look at the groups and see
www-data //www-data exists.
groups el //see that el is part of www-data
el : www-data
Run Code Online (Sandbox Code Playgroud)
立即重新启动终端以确保用户和组已生效.以el登录
vi /foobar/test_file //try to edit the file.
Run Code Online (Sandbox Code Playgroud)
产生警告:
Warning: W10: Warning: Changing a readonly file"
Run Code Online (Sandbox Code Playgroud)
什么?我已经做好了一切,为什么它不起作用?
回答:
完全重启计算机.停止终端不足以解决这些问题.
我认为发生的事情是apache2也使用www-data组,因此任务以某种方式阻止了用户和组的正确执行.您不仅需要注销,还必须停止并重新启动使用您的组的任何服务.如果重新启动没有得到它,你就会遇到更大的问题.
Las*_*osi 12
我遇到了同样的问题,检查文件夹是否还有ACL规则!
如果列出文件夹时可以看到+(加号),则表示它具有特殊的访问规则.例如:
[user_in_apache_group@web02 html]$ ls -l
total 16
drwxrwxr-x 16 apache apache 4096 Sep 4 13:46 ilias
drwxrwxr-x+ 15 apache apache 4096 Sep 4 13:46 ilias5
Run Code Online (Sandbox Code Playgroud)
查看权限:
[user_in_apache_group@web02 html] getfacl ilias5
# file: ilias5
# owner: apache
# group: apache
user::rwx
user:user_in_apache_group:r-x
group::rwx
mask::rwx
other::r-x
Run Code Online (Sandbox Code Playgroud)
这意味着我的用户(user_in_apache_group)没有该文件夹的写入权限.
解决方案是@techtonik所说的,为用户添加写权限:
[user_in_apache_group@web02 html]$ sudo setfacl -m u:user_in_apache_group:rwx ./ilias5
Run Code Online (Sandbox Code Playgroud)
再次检查权限:
[user_in_apache_group@web02 html] getfacl ilias5
...
user:user_in_apache_group:rwx
...
Run Code Online (Sandbox Code Playgroud)
希望能帮助到你.;)
使用Linux ACL(访问控制列表) - 它是权限系统的更细粒度版本,
setfacl -R -m 'group:staff:rwx' -m 'd:group:staff:rwx' /usr/local/lib/R/
Run Code Online (Sandbox Code Playgroud)
这将为其中创建的任何内容设置目录和默认权限的活动权限.
如果您刚刚将自己添加到staff组中,则无法在没有重新登录的情况下工作,但您可以仅为当前会话设置权限.