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用户登录,因为红旗安装过后默认的登录 ...
随机推荐
- Sublime配置Python & sublime操作
前言 前几天我发了一个配置C++的博客,今天再给大家掏一掏Python如何配置.但是主要是操作,文件并没有很多. 正文 文件地址:python 提取码:3gb7 先全部解压,sublime就按照上面说 ...
- linux ubuntu 18首次使用root权限
第一次获得root密码: sudo passwd root 切换成root用户,获得root权限 exit 退出,回到初始用户
- JSP标签介绍
JSP标签也称之为Jsp Action(JSP动作)元素,它用于在Jsp页面中提供业务逻辑功能,避免在JSP页面中直接编写java代码,造成jsp页面难以维护. jsp的常用标签有以下三个 <j ...
- 连接池你用对了吗?一次Unexpected end of stream异常的排查
能收获什么? 更加了解TCP协议 Redis与客户端关闭连接的机制 基于Apache Common连接池的参数调优 Linux网络抓包 情况简介 近期迁移了部分应用到K8s中,业务开发人员反馈说,会发 ...
- 如何通过php 使用异或(XOR)加密/解密文件
laravel代码如下: /** * @param $q * @param $k * @return string 异或加解密 */ public function jiajiemi($q,$k){ ...
- js数组增删元素
操作数组的方法 push() 结尾添加 数组.push(元素) 参数 描述 newelement1 必需.要添加到数组的第一个元素. newelement2 可选.要添加到数组的第二个元素. newe ...
- JavaScript之深入对象(二)
上一篇随笔讲解了构造函数.原型及原型链相关的知识,今天让我们一起来探讨另一个问题:this. 一 this 的指向 1, 函数预编译过程中,this指向window 我们在讲解函数预编译过程 ...
- python最基本的数据掌握
python初学者可能会对list数据类型和int或者是字符串数据类型比较迷茫 list是引用,是指向的一个内存地址, 变量不是引用的 啥也不说上解释: a = 1 b = a a = 2 prin ...
- React-leaflet在ant-design pro中的基本使用
react-leaflet的github地址:https://github.com/PaulLeCam/react-leaflet react-leaflet-markercluster点聚合gith ...
- DefaultSerializer requires a Serializable payload but received an object of type [model.Admin]
一.问题描述: 在用redis做二级缓存时,出现如下异常 DefaultSerializer requires a Serializable payload but received an o ...