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

相关推荐
MwEUwQ3Gx8 小时前
常见Linux权限提升笔记
linux·运维·笔记
bIo7lyA8v8 小时前
如何用SSH访问远程服务器上的内网服务(如:MySQL、Redis、Kafka)?
服务器·mysql·ssh
小邓睡不饱耶8 小时前
花店花品信息管理系统开发实战:Python实现简易门店管理系统
服务器·python·microsoft
ken22328 小时前
安装问题@ ubuntu 24.04 :efi 磁盘分区,挂载
linux·运维·ubuntu
white-persist8 小时前
【vulhub weblogic CVE-2017-10271漏洞复现】vulhub weblogic CVE-2017-10271漏洞复现详细解析
java·运维·服务器·网络·数据库·算法·安全
数据知道9 小时前
claw-code 源码详细分析:`reference_data` JSON 快照——大型移植里「对照底稿」该怎么治理与演进?
linux·python·ubuntu·json·claude code
kvo7f2JTy9 小时前
吃透Linux/C++系统编程:文件与I/O操作从入门到避坑
java·linux·c++
Deitymoon9 小时前
linux——守护进程
linux
TON_G-T9 小时前
useEffect为什么会触发死循环
java·服务器·前端
tHeya06II9 小时前
涵盖 Cursor、Claude Code、Skills
java·服务器