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用户登录,因为红旗安装过后默认的登录 ...
随机推荐
- 剑指offer】Java版代码(完整版)
转自:剑指offer]Java版代码(完整版) 转自:[剑指offer] JAVA版题解(完整版)
- 3、循环链表(java实现)
1.节点类 public class Node<T> { public T data; public Node next; } 2.实现类 public class CircularLin ...
- 取html里的img和去html标签
C# : public string RemoveHTML(string html) { html = Regex.Replace(html, @"<script[^>]*?& ...
- 【读书笔记】C++ primer 5th 从入门到自闭(一)
这几天看了C++ primer 5th的一二章,有很多收获,但是有的地方因为翻译的问题也搞得理解起来颇为难受啊啊啊啊.尤其是const限定符,在C语言并没有这么多复杂的语法,在C++里面语法细节就多的 ...
- Matplotlib散点图、条形图、直方图-02
对比常用统计图 折线图: 特点:能够显示数据的变化趋势,反映事物的变化情况.(变化) 直方图: 特点:绘制连续性的数据,展示一组或者多组数据的分布情况(统计) 条形图: 特点:绘制离散的数据,能够一眼 ...
- 远古框架-SSH maven配置 (包含gson)
Spring3.2.17+Struts2.3.15+Hibernate3.6.10 <?xml version="1.0" encoding="UTF-8" ...
- 【已解决】关于IDEA中 Tomcat 控制台打印日志中文乱码的解决
在 Idea 上面使用 Tomcat 时,发现控制台打印信息的时候,出行中文乱码问题; 可以通过以下几种解决办法 1:在-Dfile.encoding=UTF-8 在vm中设置编码方式 2.然后从Fi ...
- tomcat 配置jvm参数
设置JVM参数在Windows下,在$TOMCAT_HOME/bin/catalina.bat,Linux下,在$TOMCAT_HOME/bin/catalina.sh的前面,增加如下设置: JAVA ...
- java通过代理创建Conncection对象与自定义JDBC连接池
最近学习了一下代理发现,代理其实一个蛮有用的,主要是用在动态的实现接口中的某一个方法而不去继承这个接口所用的一种技巧,首先是自定义的一个连接池 代码如下 import java.lang.reflec ...
- asp.net core 使用Mysql和Dapper
序曲:学习编程最好的方式就是敲代码,没有比这个更好的方法,哪怕你看了上百G的视频,都不如你自己敲几行代码更为有效.还有要记得敲完代码然后写一篇随笔来记录一下你所学所想. 大家都知道,.netcore是 ...