当前位置:网站首页>setfacl命令的基本用法
setfacl命令的基本用法
2022-06-23 22:26:00 【noravinsc】
1、setfacl的用途
setfacl命令可以用来细分linux下的文件权限。
chmod命令可以把文件权限分为u,g,o三个组,而setfacl可以对每一个文件或目录设置更精确的文件权限。
换句话说,setfacl可以更精确的控制权限的分配。
比如:让某一个用户对某一个文件具有某种权限。
这种独立于传统的u,g,o的rwx权限之外的具体权限设置叫ACL(Access Control List)
ACL可以针对单一用户、单一文件或目录来进行r,w,x的权限控制,对于需要特殊权限的使用状况有一定帮助。
如,某一个文件,不让单一的某个用户访问。
2、setfacl的用法
看一个例子:
[[email protected] ~]# getfacl test #查看acl
file: test
owner: root
group: root
user::rw-
group::r–
other::r–
[[email protected] ~]# setfacl -m u:tank:rx test #给tank用户向test文件增加读和执行的acl规则
[[email protected] ~]# getfacl test #查看acl
file: test
owner: root
group: root
user::rw-
user:tank:r-x #已加入
group::r–
mask::r-x
other::r–
[[email protected] ~]# setfacl -m u::rwx test #设置默认用户,读,写,可执行
[[email protected] ~]# getfacl test
file: test
owner: root
group: root
user::rwx
user:tank:r-x
group::r–
mask::r-x
other::r–
[[email protected] ~]# setfacl -b test #清除所有acl
[[email protected] ~]# getfacl test
file: test
owner: root
group: root
user::rwx
group::r–
other::r–
[[email protected] ~]# setfacl -m u:tank:rx test #给tank用户向test文件增加读和执行的acl规则
[[email protected] ~]# setfacl -m u:testtank:rx test #给testtank用户向test文件增加读和执行的acl规则
[[email protected] ~]# getfacl test
file: test
owner: root
group: root
user::rwx
user:testtank:r-x
user:tank:r-x
group::r–
mask::r-x
other::r–
[[email protected] ~]# setfacl -x u:tank test #清除tank用户,对test文件acl规则
[[email protected] ~]# getfacl test
file: test
owner: root
group: root
user::rwx
user:testtank:r-x
group::r–
mask::r-x
other::r–
设置组的话只需要把setfacl -m u::rwx 中的u改为g即可,大致差不多。
设置mask的话,setfacl -m u::rwx 中的u改为m,并且这个可不针对用户和组哦,其他的大致差不多。
在使用-R时,记得放在-m前面,否则不可以地
使用-d的话,就会把默认的都加上去,针对目录哦。
边栏推荐
- Summary of common register bit operation modes in MCU
- The first open-source MySQL HTAP database in China will be released soon, and the three highlights will be informed in advance that shiatomics technology will launch heavily
- Social order in the meta universe
- Android App bundle exploration, client development interview questions
- 抖音实战~密码找回
- What is the use of AI technology in the medical field?
- Solve the problem of project dependency red reporting
- WPF效果之Expander+ListBox
- What is medical treatment? AI medical concept analysis AI
- Startup process analysis of APP performance optimization
猜你喜欢

被同事坑到周末加班, 没见过把Redis用成这个鬼样子的。。。

Android 3年外包工面试笔记,有机会还是要去大厂学习提升,作为一个Android程序员

Quantitative investment model -- research interpretation of high frequency trading market making model (Avellaneda & Stoikov's) & code resources

Keywords such as extern and struct

985本3Android程序员40天拿下阿里P6口头offer,面试成功后整理了这些面试思路

CPU取指到发出控制、微程序控制原理详细过程

Test - use case - detail frenzy

Confused test / development programmers, different people have different stories and different puzzles

混沌工程,了解一下
![[FreeRTOS] 07 binary semaphore and count semaphore](/img/9c/a3e4b9e02f754c5d3a54d94b7b4e35.png)
[FreeRTOS] 07 binary semaphore and count semaphore
随机推荐
First week of summer vacation
C语言:利用自定义函数排序
extern、struct等关键字
Android 7,2021最新Android面试笔试题目分享
节流和防抖
Usage of go in SQL Server
利用Scanorama高效整合异质单细胞转录组
医疗是什么?AI医疗概念解析AI
Social order in the meta universe
CPU取指到发出控制、微程序控制原理详细过程
毕业设计-论文写作笔记【毕设题目类型、论文写作细节、毕设资料】
Chinese guide to accompanist component library - glide, hot
SQL Server 中 GO 的用法
Andorid 开发艺术探索笔记(2),跨平台小程序开发框架
2. camera calibration
Vulnerability recurrence - redis vulnerability summary
== 和 equals 的区别是什么?
Comment utiliser l'entrepôt de données pour créer une table de synchronisation
Startup process analysis of APP performance optimization
All 32 keyword classifications of C language C89 (C90)