小知识 - 恢复chmod执行权限

误删除了chmod 执行权限怎么处理

原理
root 用户通过chmod 命令给不同的文件访问者设置相应的权限,但root 用户不能执行对自己没有执行权限的文件
解决方式
linux 中可通过ACL 权限让root 用户 为特定用户或用户组设置权限

#1.演示问题,删除chmod 的所有权限
[root@CentOS8 ~]#ll /bin/chmod
-rwxr-xr-x. 1 root root 76904 May 12  2019 /bin/chmod
[root@CentOS8 ~]#chmod 000 /bin/chmod
[root@CentOS8 ~]#ll /bin/chmod
----------. 1 root root 76904 May 12  2019 /bin/chmod

#2.通过ACL 权限给root 用户设置rwx 权限
[root@CentOS8 ~]#setfacl -m u:root:rwx /bin/chmod
[root@CentOS8 ~]#getfacl /bin/chmod
getfacl: Removing leading '/' from absolute path names
# file: bin/chmod
# owner: root
# group: root
user::---
user:root:rwx
group::---
mask::rwx
other::---

#3.通过chmod 命令给用户root 恢复原有权限
[root@CentOS8 ~]#chmod 755 /bin/chmod
[root@CentOS8 ~]#getfacl /bin/chmod
getfacl: Removing leading '/' from absolute path names
# file: bin/chmod
# owner: root
# group: root
user::rwx
user:root:rwx			#effective:r-x
group::---
mask::r-x
other::r-x

#4.取消ACL 权限给root 用户设置的rwx 权限
[root@CentOS8 ~]#setfacl -b /bin/chmod
[root@CentOS8 ~]#getfacl /bin/chmod
getfacl: Removing leading '/' from absolute path names
# file: bin/chmod
# owner: root
# group: root
user::rwx
group::---
other::r-x

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值