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

相关推荐
数据要素X1 分钟前
寻梦数据空间 | 架构篇:从概念到落地的技术实践与突破性创新
大数据·运维·数据仓库·微服务·数据治理·数据中台·可信数据空间
玉石观沧海20 分钟前
高压变频器故障代码解析F67 F68
运维·经验分享·笔记·分布式·深度学习
海阳宜家电脑27 分钟前
SQL Server连接字符串
服务器·网络
努力学习的小廉1 小时前
深入了解linux网络—— 自定义协议(上)
linux·服务器·网络
bcgbsh1 小时前
Linux开机启动脚本(cron 的 @reboot 特性)
linux·cron
听风吹雨yu2 小时前
RK3588从数据集到训练到部署YoloV8
linux·yolo·开源·rk3588·rknn
野犬寒鸦2 小时前
从零起步学习Redis || 第十一章:主从切换时的哨兵机制如何实现及项目实战
java·服务器·数据库·redis·后端·缓存
要做朋鱼燕2 小时前
【AES加密专题】1.AES的原理详解和加密过程
运维·网络·密码学·c·加密·aes·嵌入式工具
yunson_Liu2 小时前
jenkins更新了gitlab后出现报错
运维·gitlab·jenkins
iconball2 小时前
个人用云计算学习笔记 --19 (MariaDB服务器)
linux·运维·笔记·学习·云计算