sudo 提示 'xxx is not in the sudoers file.This incident will be reported.的解决方法'
在使用 Linux 的过程中,有时候需要临时获取 root 权限来执行命令时,一般通过在命令前添加 sudo 来解决。
但是第一次使用 sudo 时,有可能会得到这样一个错误提示
xxx is not in the sudoers file.This incident will be reported.的解决方法
xxx代表你当前的用户名。
出现该问题的原因是,在通过 sudo 获取 root 权限之前,用户需要先获得使用 sudo 命令的权限。
通过简单的搜索,我得知 sudo 命令的配置由 /etc/sudoers 文件来定义,所以我们要通过修改这个配置文件来让当前的用户获得 sudo 命令的权限。
我果断地执行了 vim /etc/sudoers ,然后看到下面的画面

放在 /etc 下的文件当然只有 root 能操作,于是我使用 su 切换成 root
我再一次执行了 vim /etc/sudoers

发现居然是个只读的文件, 我用下面的命令查看了这个文件的权限设置
[x@1lin24 ~]$ ls -l /etc/sudoers
-r--r----- 1 root root 3955 Oct 18 09:50 /etc/sudoers
这个文件对于 root 只有读的权限。但文件开头提醒我们,编辑这个文件只能使用 visudo。
当然,我在网上也看到过,给 /etc/sudoers 添加了写的权限,设置完之后再取消掉。
这里不建议这样,首先,官方已经给出了不修改文件读写权限的方法,另一方面,修改权限的操作容易出现失误或者遗漏。
有了 visudo ,我们要看一下如何来配置,下面我列举了几个比较常用的配置语法:
username ALL=(ALL) ALL # 允许用户执行 sudo 命令(需要输入密码)
%username ALL=(ALL) ALL # 允许用户组执行 sudo 命令 (需要输入密码)
username ALL=(ALL) NOPASSWD: ALL # 允许用户执行 sudo 命令 (不需要输入密码
%username ALL=(ALL) NOPASSWD: ALL # 允许用户组执行 sudo 命令 (不需要输入密码
sudo 提示 'xxx is not in the sudoers file.This incident will be reported.的解决方法'的更多相关文章
- Linux遇到的问题(一)Ubuntu报“xxx is not in the sudoers file.This incident will be reported” 错误解决方法
提示错误信息 www@iZ236j3sofdZ:~$ ifconfig Command 'ifconfig' is available in '/sbin/ifconfig' The command ...
- centos添加和删除用户及 xxx is not in the sudoers file.This incident will be reported.的解决方法
修改主机名:vim /etc/sysconfig/network 1.添加用户,首先用adduser命令添加一个普通用户,命令如下: #adduser tommy //添加一个名为tommy的用户 # ...
- 解决:xxx is not in the sudoers file.This incident will be reported.的解决方法
Linux中普通用户用sudo执行命令时报”xxx is not in the sudoers file.This incident will be reported”错误,解决方法就是在/etc/s ...
- 企业运维案例:xxx is not in the sudoers file.This incident will be reported” 错误解决方法
CentOS6系统下,普通用户使用sudo执行命令时报错: xxx is not in the sudoers file.This incident will be reported" 解决 ...
- Ubuntu——"xxx is not in the sudoers file.This incident will be reported" 错误解决方法
Ubuntu下普通用户用sudo执行命令时报如题所示错误,解决方法就是在/etc/sudoers文件里给该用户添加权限.如下: 1.切换到root用户下 2./etc/sudoers文件默认是只读的, ...
- xxx is not in the sudoers file.This incident will be reported.的解决方法 (一般用户不能执行sudo)
1.切换到root用户下 2.添加sudo文件的写权限,命令是:chmod u+w /etc/sudoers 3.编辑sudoers文件vi /etc/sudoers找到这行 root ALL=(AL ...
- 普通用户开通sudo权限:xxx is not in the sudoers file.This incident will be reported.的解决方法
1.切换到root用户下,怎么切换就不用说了吧,不会的自己百度去. 2.添加sudo文件的写权限,命令是: chmod u+w /etc/sudoers 3.编辑sudoers文件 vi /etc/s ...
- xxx is not in the sudoers file.This incident will be reported.的解决方法
1.切换到root用户下,怎么切换就不用说了吧,不会的自己百度去. 2.添加sudo文件的写权限,命令是:chmod u+w /etc/sudoers 3.编辑sudoers文件vi /etc/sud ...
- xxx is not in the sudoers file. This incident will be reported的解决方法
1>.进入超级用户模式.也就是输入"su -",系统会让你输入超级用户密码,输入密码后就进入了超级用户模式.(当然,你也可以直接用root用户登录,因为红旗安装过后默认的登录 ...
随机推荐
- Spring事务失效的2种情况
使用默认的事务处理方式 因为在java的设计中,它认为不继承RuntimeException的异常是”checkException”或普通异常,如IOException,这些异常在java语法中是要求 ...
- (转)为什么HashMap中链表长度超过8会转换成红黑树
原博地址:https://blog.csdn.net/xingfei_work/article/details/79637878 HashMap在jdk1.8之后引入了红黑树的概念,表示若桶中链表元素 ...
- python判断一个数是否为整数
- 3、循环链表(java实现)
1.节点类 public class Node<T> { public T data; public Node next; } 2.实现类 public class CircularLin ...
- flex布局笔记整理
flex布局笔记整理 了解-webkit-box 利用postcss进行css代码的向后兼容时,display:flex兼容后的代码常会带有display:-webkit-box. 部分移动端内核较低 ...
- Mysql中有符号数和无符号数的区别
1原文地址:https://blog.csdn.net/s78365126/article/details/85048882 2可以手写sql验证一下 3mysql无符号和有符号的区别无符号unsig ...
- jsp学习:jsp学习阶段性总结2019.9.21
Jsp学习 jsp语法格式: 脚本程序:<% 代码片段 %> jsp声明:<%! declaration; [ declaration; ]+ ... %> 表达式:<% ...
- 微信小程序删除数组(删除对应指定下标数组中的元素)
.js 使用arr.splice(id,1)删除 // 删除数组中指定下标 dele_time: function (e) { console.log('删除') console.log(e.curr ...
- PTA A1009&A1010
第五天 A1009 Product of Polynomials (25 分) 题目内容 This time, you are supposed to find A×B where A and B a ...
- Sping学习笔记(一)----Spring源码阅读环境的搭建
idea搭建spring源码阅读环境 安装gradle Github下载Spring源码 新建学习spring源码的项目 idea搭建spring源码阅读环境 安装gradle 在官网中下载gradl ...