当前位置:网站首页>14、用户、组和权限(14)
14、用户、组和权限(14)
2022-07-05 18:44:00 【51CTO】
文件系统的特殊权限
linux中有三种常见权限,还有三种特殊权限:suid,sgid,sticky
特殊权限suid
前提:进程有属主和属组,文件有属主和属组 (占据user的执行权限位, 数字法为4)
1、任何进程一个可执行程序文件能不能启动为进程,取决于发起者对程序文件是否具有执行权限
2、启动为进程之后,其进程属主为发起者,进程属组为发起者所属组
3、进程访问文件时的权限,取决于进程的发起者
a、进程的发起者,同文件的属主:则应用文件属主权限
b、进程的发起者,属于文件属组:则应用文件属组权限
c、应用文件其他权限
二进制的可执行文件上suid权限功能
任何一个可执行文件能不能启动为进程:取决于发起者对程序文件是否有执行权限
启动为进程之后,其进程的属主为原程序文件的属主
suid只对二进制可执行程序有效
suid设置在目录上无意义
suid 权限设定
chmod u+s file... chmod 6xxx file chmod u-s file ...
去掉s权限后,出现更改密码报错
重新赋予suid权限后可更新成功(结论:具有suid的权限;lgw用户调用passwd命令时,能临时获取到/usr/bin/passwd的属主的权限然后对shadows进行更新)
特殊权限sgid
二进制可执行文件上的sgid权限功能(占据group的执行权限位, 数字法为2)
任何一个可执行程序文件能不能驱动为进程:取决于发起者对程序文件是否有执行权限
启动为进程之后,其进程的属组为源程序文件的属主
sgid权限的设定 chmod g+s file... chmod 2xxx file chmod g-s file...
目录上sgid权限功能:默认情况下,用户创建文件时,其属组为此用户所属的主组,一但某目录被设定为sgid,则对此目录有写权限的用户在此目录中创建的文件所属的组为此目录的属组,通常用于创建一个协作目录。
特殊权限sticky
具有写权限的目录通常用户可以删除该目录中的任何文件,无论该文件的权限或拥有权限在马艳玲设置sticky位,只有文件的所有者或root可以删除该文件。(占据other的执行权限位, 数字法为1)
sticky权限设定 chmod o+t dir chmod 1xxx dir chmod o-t dir
other对/tmp目录具有写权限,理论上可以删除该目录下任何文件,但是加入sticky权限后,不能
设定文件的特殊属性
设定文件的特殊属性,可以访问root用户误操作或修改文件
不能删除,改名,更改 chattr +i
只能追加内容,不能删除,改名 chattr +a
列出特定属性 lsattr
访问控制列表(ACL)
acl:access control list 实现灵活的权限管理
除了文件所属主、所属组和other,可以对更多用户进行权限设置
centos7默认创建的xfs和ext4文件系统具有acl功能
tune2fs -o acl /dev/sdb1 mount -o acl /dev/sdb1 /mnt
acl生效顺序:所有者、自定义用户、所属组|自定义组,其他人
相关命令setfacl、getfacl
setfacl 设置acl权限
getfacl 查看设置的acl权限
mask权限
mask只影响所有者和other之外的人和组的最大权限
mask需要与用户的前行进行逻辑与运算后,才能变成有效的权限(effectice permission)
用户或组的设置必须存在于mask权限设定范围内才会生效
setfacl -m mask::rx file
other设置了acl权限为rwx,导致mask也为rmx
setfacl --set u::rw,u:wang:rw,g::r,o::- file1 --setfacl选项会把原有的acl项都删除,用新的替代,需要注意的是一定要宝行ugo的设置,不能像-m一样只是添加acl就可以
备份还原acl
主要文件操作命令为cp和mv都支持acl,只要cp命令需要加上-p参数,但是tar等常见的备份工具是不会保留目录和文件的acl信息
备份acl getfacl -R /tmp/dir > acl.txt
消除acl setfacl -R -b /tmp/dir
还原acl setfacl -R --set-file=acl.txt /tmp/dir
查看acl getfacl -R /tmp/dir
边栏推荐
- Interviewer: what is the difference between redis expiration deletion strategy and memory obsolescence strategy?
- You can have both fish and bear's paw! Sky wing cloud elastic bare metal is attractive!
- android中常见的面试题,2022金九银十Android大厂面试题来袭
- 5年经验Android程序员面试27天,2022程序员进阶宝典
- 使用文件和目录属性和属性
- 【历史上的今天】7 月 5 日:Google 之母出生;同一天诞生的两位图灵奖先驱
- 7-1 链表也简单fina
- Lombok @builder annotation
- 2022最新Android面试笔试,一个安卓程序员的面试心得
- Taishan Office Technology Lecture: from the layout height of the line, talk about the height overflow and height shrinkage of the drawing height (launched in the whole network)
猜你喜欢
android中常见的面试题,2022金九银十Android大厂面试题来袭
技术分享 | 接口测试价值与体系
How to quickly advance automated testing? Listen to the personal feelings of the three bat test engineers
AI open2022 | overview of recommendation systems based on heterogeneous information networks: concepts, methods, applications and resources
Postman核心功能解析 —— 参数化和测试报告
Technology sharing | interface testing value and system
MySQL优化六个点的总结
The era of Web3.0 is coming. See how Tianyi cloud storage resources revitalize the system to enable new infrastructure (Part 2)
2022全网最全的腾讯后台自动化测试与持续部署实践【万字长文】
Tupu software digital twin | visual management system based on BIM Technology
随机推荐
R language uses lubridate package to process date and time data
从外卖点单浅谈伪需求
蚂蚁集团开源可信隐私计算框架「隐语」:开放、通用
进程间通信(IPC):共享内存
Oracle 中文排序 Oracle 中文字段排序
Ant group open source trusted privacy computing framework "argot": open and universal
如何快速进阶自动化测试?听听这3位BAT大厂测试工程师的切身感想....
1亿单身男女撑起一个IPO,估值130亿
Postman核心功能解析 —— 参数化和测试报告
Use file and directory properties and properties
视频融合云平台EasyCVR增加多级分组,可灵活管理接入设备
[HCIA cloud] [1] definition of cloud computing, what is cloud computing, architecture and technical description of cloud computing, Huawei cloud computing products, and description of Huawei memory DD
Word finds red text word finds color font word finds highlighted formatted text
C# 语言的高级应用
尚硅谷尚优选项目教程发布
Taishan Office Technology Lecture: from the layout height of the line, talk about the height overflow and height shrinkage of the drawing height (launched in the whole network)
R language Visual scatter plot graph, add labels to some data points in the graph, and always display all labels, even if they have too much overlap. Ggrep package helps
机器学习基础(三)——KNN/朴素贝叶斯/交叉验证/网格搜索
The road of enterprise digital transformation starts from here
使用文件和目录属性和属性