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

相关推荐
..过云雨23 分钟前
13.【Linux系统编程】从ELF格式深入理解动静态库
linux·c语言·c++·后端
xingyue_S38 分钟前
LVS负载均衡群集(二)-- DR模式
运维·负载均衡·lvs
一名机电研究生39 分钟前
华为、阿里巴巴、字节跳动 100+ Linux面试问题总结(一)
linux·华为·面试
朝九晚五ฺ40 分钟前
用Rust从零实现一个迷你Redis服务器
服务器·redis·rust
讨厌下雨的天空42 分钟前
环境变量与地址
linux
阿巴~阿巴~1 小时前
深入解析UDP服务器核心开发机制
linux·服务器·网络协议·网络编程·udp服务器·recvfrom函数
q***31891 小时前
如何查询SQL Server数据库服务器的IP地址
服务器·数据库·tcp/ip
roman_日积跬步-终至千里1 小时前
【Nginx】Nginx 多协议负载均衡实战:StarRocks 与 MinIO 代理配置全解析
运维·nginx·负载均衡
lwhdjbcjdjd1 小时前
Nginx实战指南:反向代理与负载均衡的原理与配置
运维·nginx·负载均衡