• ubuntu:xxx is not in the sudoers file. 问题解决


    ubuntu 下普通用户用 sudo 执行命令时报 "xxx is not in the sudoers file.This incident will be reported" 错误,解决方法是在 /etc/sudoers 文件里给该用户添加权限。操作过程如下:

    1. 切换到 root 用户下
    
    2. /etc/sudoers 文件默认是只读的,对 root 来说也是,因此需先添加 sudoers 文件的写权限,命令是:
        chmod u+w /etc/sudoers
    
    3. 编辑 sudoers 文件
        vi /etc/sudoers
    
    找到这行 root ALL=(ALL) ALL,在他下面添加
        xxx ALL=(ALL) ALL (这里的 xxx 是你的用户名)
    
    PS:这里说下你可以 sudoers 添加下面四行中任意一条
    
    /*******************************************/
    youuser     ALL=(ALL)   ALL
    %youuser    ALL=(ALL)   ALL
    youuser     ALL=(ALL)   NOPASSWD: ALL
    %youuser    ALL=(ALL)   NOPASSWD: ALL
    
    第一行:允许用户 youuser 执行 sudo 命令(需要输入密码)。
    第二行:允许用户组 youuser 里面的用户执行 sudo 命令(需要输入密码)。
    第三行:允许用户 youuser 执行 sudo 命令,并且在执行的时候不输入密码。
    第四行:允许用户组 youuser 里面的用户执行 sudo 命令,并且在执行的时候不输入密码。
    /*******************************************/
    
    4.撤销 sudoers 文件写权限,命令:
        chmod u-w /etc/sudoers
    
  • 相关阅读:
    57. Insert Interval
    56. Merge Intervals
    55. Jump Game
    54. Spiral Matrix
    52. N-Queens II
    More Effective C++ 条款2 最好使用C++转型操作符
    More Effective C++ 条款1 仔细区别pointers和references
    Python_内置函数之max
    python_超级基础
    python_format格式化输出、while else、逻辑运算符、编码初识
  • 原文地址:https://www.cnblogs.com/GyForever1004/p/10436414.html
Copyright © 2020-2023  润新知