大网数据广告活动
服务器运维问答

How to give write permissions using setfacl while retaining existing permissions?

· 52CE 我爱测

I want to give write permission to a specific user on a dir recursively without loosing any existing permissions that the user may have. I believe I can use something like this to give write permissions to the user: setfacl -R -m…

问题原文

原帖链接 · comatose · CC BY-SA 3.0

I want to give write permission to a specific user on a dir recursively without loosing any existing permissions that the user may have. I believe I can use something like this to give write permissions to the user:

setfacl -R -m u:user:w dir/*

but the issue with this is that it takes away any existing permissions that the user may already have. For example if the user had execute permissions before executing the setfacl command, it will replace the execute permission with write permissions.

How can I give write permission to the user while retaining the existing permissions?

社区高分解答

原帖链接 · shodanshok · CC BY-SA 4.0

What you want are called "relative permissions", a feature that some setfacl implementation provide, basically using the classic "+/-" syntax used by chmod

However, on RHEL7 and Ubuntu 16.04 LTS at least, setfacl does not provide such feature. For example, something as setfacl -m user:root:+r /root/ return an error stating setfacl: Option -m: Invalid argument near character 11

If your setfacl implementation lacks this feature, you have two possibilities:

  • use getfacl to output all the ACLs to a file, editing such a file to match your required access permission, then use setfacl --restore to load/apply the new permissions;
  • create a script to iterate on each file, read the current ACLs and write the new access permissions.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2017-08-01)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0 / CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。