当前位置:网站首页>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

边栏推荐
- How to choose the notion productivity tools? Comparison and evaluation of notion, flowus and WOLAI
- Inventory of the most complete low code / no code platforms in the whole network: Jiandao cloud, partner cloud, Mingdao cloud, Qingliu, xurong cloud, Jijian cloud, treelab, nailing · Yida, Tencent clo
- 【硬核干货】数据分析哪家强?选Pandas还是选SQL
- Is it safe for Guosen Securities to open an account online?
- 测试的核心价值到底是什么?
- Debezium series: modify the source code to support drop foreign key if exists FK
- 【obs】libobs-winrt :CreateDispatcherQueueController
- How about testing outsourcing companies?
- Worthy of being a boss, byte Daniel spent eight months on another masterpiece
- third-party dynamic library (libcudnn.so) that Paddle depends on is not configured correctl
猜你喜欢

aggregate

UWB ultra wideband positioning technology, real-time centimeter level high-precision positioning application, ultra wideband transmission technology

JVMRandom不可设置种子|问题追溯|源码追溯

Add data to excel small and medium-sized cases through poi

CADD课程学习(7)-- 模拟靶点和小分子相互作用 (半柔性对接 AutoDock)

Android interview, Android audio and video development

Bitcoinwin (BCW) was invited to attend Hanoi traders fair 2022

Necessary skills for interview in large factories, 2022android will not die, I will not fall

Fundamentals of deep learning convolutional neural network (CNN)

城链科技数字化创新战略峰会圆满召开
随机推荐
微波雷达感应模块技术,实时智能检测人体存在,静止微小动静感知
SecureRandom那些事|真伪随机数
Multi branch structure
[Collection - industry solutions] how to build a high-performance data acceleration and data editing platform
测试的核心价值到底是什么?
[AI framework basic technology] automatic derivation mechanism (autograd)
okcc呼叫中心有什么作用
Relationship between floating elements and parent and brother boxes
C - sequential structure
使用 RepositoryProvider简化父子组件的传值
太牛了,看这篇足矣了
如何在2022年更明智地应用智能合约?
Add data to excel small and medium-sized cases through poi
城链科技数字化创新战略峰会圆满召开
测试外包公司怎么样?
线程池参数及合理设置
C#应用程序界面开发基础——窗体控制(6)——菜单栏、工具栏和状态栏控件
Wildcard selector
Bitcoinwin (BCW) was invited to attend Hanoi traders fair 2022
How to apply smart contracts more wisely in 2022?