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

相关推荐
weixin_462446237 分钟前
OpenClaw 完整部署指南:从用户创建、安装配置到 Nginx 反向代理
运维·nginx·openclaw
云飞云共享云桌面7 分钟前
SolidWorks云电脑如何多人共享访问?
运维·服务器·人工智能·3d·自动化·云计算·电脑
PenguinLetsGo17 分钟前
代码段的消失:页表异常清零引发的 ILL_ILLOPC 溯源
android·linux
AMoon丶18 分钟前
C++基础-类、对象
java·linux·服务器·c语言·开发语言·jvm·c++
指尖在键盘上舞动19 分钟前
Cannot find matching video player interface for ‘ffpyplayer‘.解决方案
linux·ubuntu·ffmpeg·psychopy·ffpyplayer
桌面运维家26 分钟前
Linux/Windows终端密码设置:保护你的vDisk数据
linux·运维·服务器
ErizJ27 分钟前
面试 | 操作系统
linux·面试·职场和发展·操作系统·os
小周学学学1 小时前
ESXI虚拟机故障关机处理记录
服务器·vmware·虚拟化
微露清风1 小时前
系统性学习Linux-第五讲-基础IO
linux·运维·学习
柏木乃一1 小时前
Linux线程(8)基于单例模式的线程池
linux·运维·服务器·c++·单例模式·操作系统·线程