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用户登录,因为红旗安装过后默认的登录 ...
随机推荐
- linux下使用yum安装新版php7.0
这两天又装了一下虚拟机,又要编译lnmp,还要弄各种拓展,很麻烦,能不能直接yum安装呢?答案是可以的! 1.首先要更新yum源,不然是默认的老版本,一般都在5.6及以下,但是php7都出来好久了,性 ...
- Spring Cloud官方文档中文版-服务发现:Eureka客户端
官方文档地址为:http://cloud.spring.io/spring-cloud-static/Dalston.SR2/#_spring_cloud_netflix 文中例子我做了一些测试在:h ...
- 零基础一年拿下BAT三家offer
背景 1.本人本科一本双非垫底的那种,硕士211.本硕电子通信,完全0基础,转行一年. 2.研一上第一学期上课+外派到老师合作公司写MATLAB.去年4月开始学习Java. 起步 1.实话说,刚决定转 ...
- Ubuntu 14.04 java环境安装配置(不是openJAVA)
两种配置方式 第一: 在 Ubuntu 中使用 PPA 安装 Java 8 ( 支持 Ubuntu 10.04 - Ubuntu 14.04 ): sudo add-apt-repository pp ...
- Tempter of the Bone(DFS+剪枝)
Problem Description The doggie found a bone in an ancient maze, which fascinated him a lot. However, ...
- 摩托罗拉GP68对讲机官方说明书下载,包含使用说明压音表和电路结构等
摩托罗拉GP68对讲机官方说明书,包含使用说明和电路结构等 1.使用说明书 链接: https://pan.baidu.com/s/1fhXXaBp-MSuQs9Sv3v_Crg 提取码: mc3e ...
- 各种浏览器UA值
UA User-Agent:用户代理,它是一个特殊字符串头,使得服务器能够识别客户使用的操作系统及版本.CPU 类型.浏览器及版本.浏览器引擎.浏览器语言.浏览器插件等. 标准格式为: 浏览器标识 ...
- TestNG(九) 异常测试
package com.course.testng.suite; import org.testng.annotations.Test; public class ExpectedExeption { ...
- CSS3-边框 border
一.圆角效果 border-radius 使用方法: border-radius:10px; /* 所有角都使用半径为10px的圆角 */ border-radius: 5px 4px 3px 2px ...
- Linux之文件与目录管理
加油!