Linux系统下xxx is not in the sudoers file解决方法

文章目录

遇到问题

服务器上新建用户,名为lishizheng,现在想给该用户添加sudo权限。

cpp 复制代码
$ sudo lsof -i tcp:7890
[sudo] password for lishizheng: 
lishizheng is not in the sudoers file.  This incident will be reported.

解决方法

登录root用户,编辑/etc/sudoers文件

cpp 复制代码
$ sudo su # 进入root账户
$ vim /etc/sudoers # 使用vim编辑sudoers文件

在User privilege specification 下面添加username

cpp 复制代码
#User privilege specification

root     ALL=(ALL:ALL) ALL

username ALL=(ALL:ALL) ALL

如下图,这里的用户名是lishizheng

使用:wq退出的时候会显示

cpp 复制代码
E45: 'readonly' option is set (add ! to override)

这时候只要使用:wq!,后面添加一个感叹号即可安全退出。

经过上述操作,新用户lishizheng就拥有了sudo权限。

参考

1 https://stackoverflow.com/questions/47806576/linux-username-is-not-in-the-sudoers-file-this-incident-will-be-reported

相关推荐
程序员-Benothing2 小时前
Shell 脚本条件判断与流程控制:if for while case 详解
linux·运维·服务器
captain3762 小时前
网络原理(3)-TCP核心机制连接管理▲▲▲
java·服务器·网络·ide·网络协议·tcp/ip·java-ee
mounter6252 小时前
统一安全域:KVM Planes 如何驾驭硬件特权级
linux·安全·linux kernel·kernel
君生我老2 小时前
Linux动静态库
linux·服务器
troy1282 小时前
Python 基础语法(一):变量、数据类型与运算符
java·服务器·python
IT摆渡者3 小时前
基于 Docker 部署 Nextcloud 私有云盘(外挂 Windows 共享)项目实践
运维·docker·容器
宵时待雨3 小时前
linux笔记归纳19:网络层协议IP
linux·网络·笔记·网络协议·tcp/ip
程序员清风3 小时前
记忆系统设计:让 Agent 拥有短期记忆与长期记忆
java·服务器·网络
做运维的阿瑞3 小时前
Linux下DNS服务器搭建
linux·运维·服务器
团子股股东峥哥3 小时前
day37-RHEL-管理基本存储
linux·运维·服务器