linux文件多个用户,linux – 如何让多个用户访问chmod()相同的文件?

在添加用户时使用Linux ACL,您不会将它们添加为文件的所有者.只是打开/修改和写入该文件的权限.

当调用chown或chmod时,有效用户ID将是例如. jacob和那个将匹配所有者的价值.如果不匹配,则命令将失败.

从男人2 chmod.

The effective UID of the calling process must match the owner of the file, or the process must be privileged (Linux: it must have the CAP_FOWNER capability).

另一种方法是将所描述的能力设置为调用进程/二进制chmod.但这会打开一个很大的安全问题,因为每个人都可以使用此命令来更改权限.

Here是一个关于用户访问功能的细粒度的线程,但它似乎不是很直接.

根据您的用例的限制,您可能希望为用户添加sudo规则以使用chmod,或者您评估用户必须在他们不拥有的文件上运行chmod的原因.也许在文件创建期间使用umask就足够了.

如果您的用户属于对目录具有写入权限的组,您还可以复制有问题的文件,删除原始文件并将副本移动到原始名称.这将导致用户将拥有复制的文件并可以执行chmod.

[user@localhost testdir]$ll

total 12K

drwxrwxr-x 2 root user 4.0K Jul 14 11:49 .

drwxr-xr-x 3 user user 4.0K Jul 14 11:47 ..

-rw-rw----+ 1 root user 5 Jul 14 11:41 testfile

[user@localhost testdir]$getfacl testfile

# file: testfile

# owner: root

# group: user

user::rw-

user:user:rw-

group::rw-

group:user:rw-

mask::rw-

other::---

[user@localhost testdir]$chmod 777 testfile

chmod: changing permissions of 'testfile': Operation not permitted

[user@localhost testdir]$cp -a testfile testfile.copy

[user@localhost testdir]$getfacl *

# file: testfile

# owner: root

# group: user

user::rw-

user:user:rw-

group::rw-

group:user:rw-

mask::rw-

other::---

# file: testfile.copy

# owner: user

# group: user

user::rw-

user:user:rw-

group::rw-

group:user:rw-

mask::rw-

other::---

[user@localhost testdir]$mv testfile.copy testfile

[user@localhost testdir]$ll

total 12K

drwxrwxr-x 2 root user 4.0K Jul 14 11:50 .

drwxr-xr-x 3 user user 4.0K Jul 14 11:47 ..

-rw-rw----+ 1 user user 5 Jul 14 11:41 testfile

[user@localhost testdir]$chmod 777 testfile

[user@localhost testdir]$ll

total 12K

drwxrwxr-x 2 root user 4.0K Jul 14 11:50 .

drwxr-xr-x 3 user user 4.0K Jul 14 11:47 ..

-rwxrwxrwx+ 1 user user 5 Jul 14 11:41 testfile

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值