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

news/2024/7/8 11:37:56

在添加用户时使用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


http://www.niftyadmin.cn/n/3660220.html

相关文章

[CSDN 视频--新闻分析第三期]:微软ohloh、Lava-Lava、破解Skype

本次视频链接: http://live.csdn.net/Issue23/LivePlay.aspx 本次新闻分析主要内容: 前微软员工合推网站 为开源开发人员指点迷津 害怕自己像缺乏经验的小白兔,闯入开放源代码的丛林吗?一群前微软员工合力推出新网站Ohloh,提供一个开源软件目录,协助开发人员评估各种开源…

tab自动补全 linux,Linux环境下python的Tab自动补全设置

步骤1:在server/scripts/py路径下编写tab.py脚本vi tab.py步骤2:将下面代码添加至tab.py脚本中,保存退出#!/usr/bin/env python# python startup fileimport sysimport readlineimport rlcompleterimport atexitimport os# tab completionrea…

linux通过ip和掩码计算网段,linux如何实现IP地址汇总,以掩码方式显示

其实这个标题名字不规范,应该叫做how to deaggregate ip ranges in linux但是deaggregate ip ranges这个语句实在是不好翻译啊。我先说下需求把,我们从纯真数据库中获得了这样的IP地址信息:58.63.253.0 58.63.253.255 广东省广州市 世纪…

linux命令 waf,命令执行WAF绕过技巧总结

原标题:命令执行WAF绕过技巧总结*本文作者:zusheng,本文属 FreeBuf 原创奖励计划,未经许可禁止转载。前言如今市面上的WAF几乎都已经具备了针对RCE攻击的防御能力,这些WAF并不是想象中毫无破绽,当Web服务器…

手机支持linux4.9,凤凰系统率先升级内核到Linux4.9 支持更多新硬件

Linux Kernel 4.9版本于12月11日正式发布,受到业内极大关注,凤凰系统(Phoenix OS)率先升级,成为全球首家应用Linux Kernel 4.9版本的安卓操作系统。近年来,移动设备市场一路高歌猛进,硬件产品多样化的趋势愈加明显。受…

[CSDN 视频--新闻分析第四期]:开源心态、流氓软件、第三代搜索

本次视频的视频链接:http://live.csdn.net/Issue24/LivePlay.aspx"微软收购Zend"假新闻看开源需要新心态近日,看到CSDN一条IT传闻,“微软1.13亿美元收购zend,PHP可能改名MSSE ”。Zend--PHP的创造者。当然,这是来自国外…

linux centos7开放端口命令,Centos7开放端口教程

在 Centos 7 或 RHEL 7 或 Fedora 中防火墙由 firewalld 来管理,而不是 iptables。一、firewalld 防火墙语法命令如下:启用区域端口和协议组合firewall-cmd [--zone] --add-port[-]/ [--timeout]此举将启用端口和协议的组合。端口可以是一个单独的端口 或…

linux ctrl d终止shell,linux中ctrl+z、ctrl+d和ctrl+c的区别

linux中ctrlz、ctrld和ctrlc的区别fg、bg、jobs、&、ctrlz都是跟系统任务有关的,虽然现在基本上不怎么需要用到这些命令,但学会了也是很实用的。&最经常被用到这个用在一个命令的最后,可以把这个命令放到后台执行ctrl z 可以将一个正…