Eric Leschin..
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
立即重新启动终端以确保用户和组已生效.以el登录
vi /foobar/test_file //try to edit the file.
产生警告:
Warning: W10: Warning: Changing a readonly file"
什么?我已经做好了一切,为什么它不起作用?
回答:
完全重启计算机.停止终端不足以解决这些问题.
我认为发生的事情是apache2也使用www-data组,因此任务以某种方式阻止了用户和组的正确执行.您不仅需要注销,还必须停止并重新启动使用您的组的任何服务.如果重新启动没有得到它,你就会遇到更大的问题.