linux 80 无权限,chmod无权限——八种解决办法

问题如下:

chmod没有权限,貌似就算是root用户也无法授权,这可咋办?chmod是设置权限的命令,但是自身没有了执行权限,那么就表示没有办法更改其他命令的权限,也没有办法改变自己的权限。

[root@localhost ~]# ll /bin/chmod

----------. 1 root root 48712 Oct 15 2014 /bin/chmod

[root@localhost ~]# chmod 755 /bin/chmod

-bash: /bin/chmod: Permission denied

解决方法1:

直接运行加载程序,并将其传递给想要运行的命令

[root@localhost ~]# /lib64/ld-linux-x86-64.so.2 /bin/chmod 755 /bin/chmod

[root@localhost ~]# ll /bin/chmod

-rwxr-xr-x. 1 root root 48712 Oct 15 2014 /bin/chmod

加载程序路径可能不同,32位系统应该是/lib/ld-linux.so,我没有测试

解决方法2:

可以使用busybox的chmod授权

[root@localhost ~]# busybox chmod 755 /bin/chmod

[root@localhost ~]# ll /bin/chmod

-rwxr-xr-x. 1 root root 48712 Oct 15 2014 /bin/chmod

解决方法3:

此方法我表示很喜欢

[root@localhost ~]# chmod 000 /bin/chmod

[root@localhost ~]# ll /bin/chmod

----------. 1 root root 48712 Oct 15 2014 /bin/chmod

[root@localhost ~]# mv /bin/chmod /bin/chmod.orig

[root@localhost ~]# cp -a /bin/chown /bin/chmod

[root@localhost ~]# dd if=/bin/chmod.orig of=/bin/chmod

95+1 records in

95+1 records out

48712 bytes (49 kB) copied, 0.00117323 s, 41.5 MB/s

解决方法4:

使用facl额外授权

[root@localhost ~]# chmod 000 /bin/chmod

[root@localhost ~]# ll /bin/chmod

----------. 1 root root 48712 Oct 15 2014 /bin/chmod

[root@localhost ~]# setfacl -m u::rx /bin/chmod

[root@localhost ~]# chmod 755 /bin/chmod

[root@localhost ~]# setfacl -b /bin/chmod

解决方法5:

复制一个可执行文件,然后使用chmod命令覆盖

[root@localhost ~]# ll /bin/chmod

----------. 1 root root 48712 Oct 15 2014 /bin/chmod

[root@localhost ~]# cp /bin/ls chmod

[root@localhost ~]# cp /bin/chmod .

cp: overwrite `./chmod'? y

[root@localhost ~]# cp -a chmod /bin/chmod

cp: overwrite `/bin/chmod'? y

[root@localhost ~]# ll /bin/chmod

-rwxr-xr-x. 1 root root 48712 May 27 10:23 /bin/chmod

解决方法6:

使用install命令的-m选项也可以设置权限

[root@localhost ~]# ll /bin/chmod

----------. 1 root root 48712 May 27 10:04 /bin/chmod

[root@localhost ~]# install -m a+x /bin/chmod .

[root@localhost ~]# ./chmod 755 /bin/chmod

[root@localhost ~]# ll /bin/chmod

-rwxr-xr-x. 1 root root 48712 May 27 10:04 /bin/chmod

解决方法7:

perl解决

[root@localhost ~]# ll /bin/chmod

----------. 1 root root 48712 Oct 15 2014 /bin/chmod

[root@localhost ~]# perl -e 'chmod 0755, "/bin/chmod"'

[root@localhost ~]# ll /bin/chmod

-rwxr-xr-x. 1 root root 48712 Oct 15 2014 /bin/chmod

解决方法8:

Python解决

[root@localhost ~]# chmod 000 /bin/chmod

[root@localhost ~]# ll /bin/chmod

----------. 1 root root 48712 Oct 15 2014 /bin/chmod

[root@localhost ~]# python -c 'import os; os.chmod("/bin/chmod", 0755)'

[root@localhost ~]# ll /bin/chmod

-rwxr-xr-x. 1 root root 48712 Oct 15 2014 /bin/chmod

喜欢 (8)or分享 (0)

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值