当前位置:网站首页>14. Users, groups, and permissions (14)
14. Users, groups, and permissions (14)
2022-07-05 19:51:00 【51CTO】
Special permissions for the file system
linux There are three common permissions in , There are also three special permissions :suid,sgid,sticky
Special privileges suid
Premise : Processes have owners and groups , The file has the owner and the group ( occupy user The execution permission bit of , The numerical method is 4)
1、 Whether an executable program file of any process can be started as a process , It depends on whether the initiator has Execution Authority on the program file
2、 After starting as a process , The process belongs to the main initiator , The process group is the initiator Group
3、 Permissions for a process to access a file , It depends on the initiator of the process
a、 The originator of the process , The owner of the same document : Then the application file belongs to the primary authority
b、 The originator of the process , Belongs to the file group : Then the file belongs to group permission is applied
c、 Apply file other permissions
Binary executable suid Authority function
Can any executable file be started as a process : It depends on whether the initiator has execution permission for the program file
After starting as a process , The owner of the process is the owner of the original program file
suid Valid only for binary executables
suid Setting on the directory makes no sense
suid Permission setting
chmod u+s file... chmod 6xxx file chmod u-s file ...
Get rid of s After permission , There is an error in changing the password
To endow with suid The permission can be updated successfully ( Conclusion : have suid Authority ;lgw The user calls passwd On command , Temporarily available /usr/bin/passwd The authority of the owner of and then on shadows updated )
Special privileges sgid
On the binary executable sgid Authority function ( occupy group The execution permission bit of , The numerical method is 2)
Can any executable program file be driven as a process : It depends on whether the initiator has execution permission for the program file
After starting as a process , The process group is the owner of the source program file
sgid Permission setting chmod g+s file... chmod 2xxx file chmod g-s file...
In the catalogue sgid Authority function : By default , When a user creates a file , Its group is the primary group to which the user belongs , Once a directory is set to sgid, The group to which the files created in this directory by users with write permission belong is the group to which this directory belongs , Usually used to create a collaboration Directory .
Special privileges sticky
A directory with write permission. Usually, the user can delete any file in the directory , No matter the permission or ownership of the file is set by Ma Yanling sticky position , Only the owner of the document or root You can delete the file .( occupy other The execution permission bit of , The numerical method is 1)
sticky Permission setting chmod o+t dir chmod 1xxx dir chmod o-t dir
other Yes /tmp Directory has write permission , Theoretically, you can delete any file in this directory , But join sticky After permission , You can't
Set the special properties of the file
Set the special properties of the file , You can visit root Users misoperate or modify files
Can't delete , Change of name , change chattr +i
Can only add content , Can't delete , Change of name chattr +a
List specific attributes lsattr
Access control list (ACL)
acl:access control list Realize flexible permission management
Except for the owner of the document 、 Group and other, You can set permissions for more users
centos7 Created by default xfs and ext4 The file system has acl function
tune2fs -o acl /dev/sdb1 mount -o acl /dev/sdb1 /mnt
acl The order of entry into force : owner 、 Custom user 、 Subordinate to the group | Custom groups , others
Relevant command setfacl、getfacl
setfacl Set up acl jurisdiction
getfacl Check the settings acl jurisdiction
mask jurisdiction
mask Only affect owners and other Maximum permissions for people and groups other than
mask After logic and operation with the user's front line , To become effective permissions (effectice permission)
User or group settings must exist in mask It will take effect only when the permission is set
setfacl -m mask::rx file
other Set up acl Permission is rwx, Lead to mask Also for the rmx
setfacl --set u::rw,u:wang:rw,g::r,o::- file1 --setfacl Option will change the original acl Delete all items , Replace... With a new one , It should be noted that we must treasure the line ugo Set up , Can not be like -m Just add acl Can
Backup restore acl
The main file operation commands are cp and mv All support acl, as long as cp The order needs to add -p Parameters , however tar And other common backup tools don't keep directories and files acl Information
Backup acl getfacl -R /tmp/dir > acl.txt
eliminate acl setfacl -R -b /tmp/dir
Restore acl setfacl -R --set-file=acl.txt /tmp/dir
see acl getfacl -R /tmp/dir
边栏推荐
- 力扣 729. 我的日程安排表 I
- 软件测试工程师是做什么的?待遇前景怎么样?
- Based on vs2017 and cmake GUI configuration, zxing and opencv are used in win10 x64 environment, and simple detection of data matrix code is realized
- Is it safe to open a mobile stock account? Is it reliable?
- Two pits exported using easyexcel template (map empty data columns are disordered and nested objects are not supported)
- 力扣 1200. 最小绝对差
- Hiengine: comparable to the local cloud native memory database engine
- CADD课程学习(7)-- 模拟靶点和小分子相互作用 (半柔性对接 AutoDock)
- 众昂矿业:2022年全球萤石行业市场供给现状分析
- What do software test engineers do? How about the prospect of treatment?
猜你喜欢
third-party dynamic library (libcudnn.so) that Paddle depends on is not configured correctl
MMO项目学习一:预热
不愧是大佬,字节大牛耗时八个月又一力作
Xaas trap: all things serve (possible) is not what it really needs
Summer Challenge database Xueba notes, quick review of exams / interviews~
【obs】QString的UTF-8中文转换到blog打印 UTF-8 char*
How to apply smart contracts more wisely in 2022?
JVMRandom不可设置种子|问题追溯|源码追溯
aggregate
Win10 x64环境下基于VS2017和cmake-gui配置使用zxing以及opencv,并实现data metrix码的简单检测
随机推荐
信息/数据
全网最全的低代码/无代码平台盘点:简道云、伙伴云、明道云、轻流、速融云、集简云、Treelab、钉钉·宜搭、腾讯云·微搭、智能云·爱速搭、百数云
Build your own website (16)
【硬核干货】数据分析哪家强?选Pandas还是选SQL
Microwave radar induction module technology, real-time intelligent detection of human existence, static micro motion and static perception
Do you know several assertion methods commonly used by JMeter?
测试的核心价值到底是什么?
使用easyexcel模板导出的两个坑(Map空数据列错乱和不支持嵌套对象)
UWB ultra wideband positioning technology, real-time centimeter level high-precision positioning application, ultra wideband transmission technology
How to safely and quickly migrate from CentOS to openeuler
Parler de threadlocal insecurerandom
Apprentissage du projet MMO I: préchauffage
[hard core dry goods] which company is better in data analysis? Choose pandas or SQL
函数的概念及语法
Jvmrandom cannot set seeds | problem tracing | source code tracing
Complete interview questions for interviewers and senior Android engineers in front-line Internet enterprises
【obs】libobs-winrt :CreateDispatcherQueueController
Common operators and operator priority
建议收藏,我的腾讯Android面试经历分享
95后阿里P7晒出工资单:狠补了这个,真香...