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

相关推荐
jiecy9 分钟前
为Linux系统双网卡配置静态路由
linux·运维
CodexDave1 小时前
数据库连接池耗尽:排查顺序与三层兜底
服务器·前端·数据库·git·云原生·容器·kubernetes
weixin_307779131 小时前
Linux下Jenkins数据故障的系统化排查Shell脚本
linux·运维·服务器·jenkins
荒--1 小时前
Burp Suite(二)
linux·运维·服务器
YangYang9YangYan1 小时前
2026自动化背景无项目经验转数据分析的可行性分析
运维·数据分析·自动化
土星云SaturnCloud2 小时前
MP_SENet轻量语音降噪模型在土星云边缘设备的部署实战
服务器·人工智能·ai·边缘计算·语音识别
internet Boy2 小时前
服务器机房硬件入门教程
运维·服务器
小白还菜2 小时前
linux(Debian)使用mdadm组磁盘RAID1阵列
linux·运维
三8442 小时前
BGP/BGP路由反射器/联邦/BGP属性/BGP选路
运维·服务器·网络
Lumistory2 小时前
超高层地标泛光照明落地:从方案到运维的避坑思路
运维·光照贴图