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

相关推荐
啦啦啦啦啦zzzz22 分钟前
共享内存的网络聊天室
linux·服务器·网络·c++·网络编程
2401_8949155335 分钟前
GEO 优化源码性能调优:高并发地域请求缓存与索引优化
java·服务器·网络·数据库·缓存
乐维_lwops1 小时前
网管平台是什么?网管工具如何选?企业网络运维的完整指南
运维·网络·网管平台
manongdashu1881 小时前
应对“SEO需要支付一年服务费”的捆绑消费,静态建站配套终身低成本服务器,全程无需额外运维开销。的方法。
运维·服务器·前端·seo·静态网站
Tanner_SL1 小时前
Linux笔记之vim操作
linux·vim
用户041328465131 小时前
Linux 查看端口占用的 6 种方法:ss、netstat、lsof 实战
linux
2301_780789661 小时前
WAF与Web应用安全的深度融合:从边界防护到业务风控
运维·服务器·网络·云原生·ddos
二宝哥1 小时前
Rocky Linux 10.2 安装 PostgreSQL 15 完整教程
linux·运维·postgresql
不会就选b1 小时前
Linux之线程池(二)
linux·运维·服务器
M78佐菲1 小时前
Linux学习笔记:进程回收、exec函数簇与线程
linux·笔记·学习·算法