zoukankan      html  css  js  c++  java
  • sudo权限造成的故障

    公司服务器故障:

    [chengsir@yinwucheng ~]$ sudo mkdir /opt/nginx
    
    sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set
    
    [chengsir@yinwucheng ~]$ su - root
    Password: 
    su: Authentication failure
    

    以下是解决方案:(前提必须要知道这个文件的默认权限)

    两种方法:
    方法一:进入单用户模式修改root密码,su和sudo没有关系,这时我们可以用su - root切到root用户,然后修改sudo权限,哪儿出了问题改哪里
    [chengsir@yinwucheng ~]$ su - root
    [root@yinwucheng ~]# ll -l /usr/bin/sudo
    -rwxrwxrwx. 1 root root 147392 Oct 31  2018 /usr/bin/sudo
    [root@yinwucheng ~]# chmod 111 /usr/bin/sudo
    [root@yinwucheng ~]# ll -l /usr/bin/sudo
    ---x--x--x. 1 root root 147392 Oct 31  2018 /usr/bin/sudo
    [root@yinwucheng ~]# chmod u+s /usr/bin/sudo
    [root@yinwucheng ~]# ll -l /usr/bin/sudo
    ---s--x--x. 1 root root 147392 Oct 31  2018 /usr/bin/sudo
    [root@yinwucheng ~]# ll -l /etc/sudoers
    -rwxrwxrwx 1 root root 4352 Aug 26 19:47 /etc/sudoers
    [root@yinwucheng ~]# chmod 440 /etc/sudoers
    [root@yinwucheng ~]# ll -l /etc/sudoers
    -r--r----- 1 root root 4352 Aug 26 19:47 /etc/sudoers
    [root@yinwucheng ~]# su - chengsir
    [chengsir@yinwucheng /opt]$ sudo mkdir cheng
    [sudo] password for chengsir:  
    [chengsir@yinwucheng /opt]$ ll
    total 0
    drwxr-xr-x 2 root root 6 Aug 26 20:04 cheng
    drwxr-xr-x 2 root root 6 Aug 26 14:52 xue
    
    方法二:进入单用户修改sudoers权限为默认初始权限即可
    重启进单用户模式:
    第一步:查看sudo权限
    ls -l /usr/bin/sudo
    第二步:给sudo权限
    chmod 111 /usr/bin/sudo
    chmod u+s /usr/bin/sudo
    第三步:给sudoers权限
    chmod 440 /etc/sudoers
    exec /sbin/init
    

    image.png

  • 相关阅读:
    python-day49--前端 css-层叠样式表
    python-day49--前端 html
    python-day48--mysql之视图、触发器、事务、存储过程、函数
    python-day47--pymysql模块
    python-day47--mysql数据备份与恢复
    python-day46--前端基础之html
    python-day45--mysql索引
    window系统下远程部署Tomcat
    tomcat下部署应用helloworld
    tomcat配置文件context.xml和server.xml分析
  • 原文地址:https://www.cnblogs.com/yinwu/p/11414617.html
Copyright © 2011-2022 走看看