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

相关推荐
cyforkk5 分钟前
Vercel 绑定自定义域名极简配置指南
服务器·前端·网络
Ai拆代码的曹操41 分钟前
K8s Pod Pending 逐层排查:从 FailedScheduling 到 PVC StorageClass 不存在的实战记录
java·linux·kubernetes
Yang96111 小时前
探索无线新视界:鼎讯信通DXMP系列频谱仪模块深度剖析
运维·网络
wangbing11252 小时前
JPA下自定义主键
java·linux·服务器
杨了个杨89822 小时前
Docker Compose 简介及应用
运维·docker·容器
bush42 小时前
正点原子imx6ull-uboot,奇怪的问题
linux·学习
Urbano2 小时前
卫衣生产工艺科普与智能自动化设备应用解析
大数据·运维·人工智能
dddwjzx2 小时前
嵌入式Linux C应用编程——Framebuffer应用编程
linux·嵌入式
lastHertz4 小时前
Nginx安装部署
运维·nginx