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

相关推荐
strive programming41 分钟前
Linux从入门到精通——基础IO(简洁清晰版)
linux·运维·服务器
节点小宝1 小时前
一站式部署:支持Windows、macOS、Linux三端的统一方案
linux·运维·macos
乌鸦9441 小时前
《库制作与原理》
linux·动态库
北亚数据恢复1 小时前
服务器数据恢复—昆腾StorNext文件系统双盘离线故障数据恢复案例
运维·服务器
ZhengEnCi1 小时前
L1D-Linux系统Node.js部署Claude Code完全指南 🚀
linux·ai编程·claude
希望永不加班1 小时前
SpringBoot 内置服务器(Tomcat/Jetty/Undertow)切换
服务器·spring boot·后端·tomcat·jetty
服务器专卖店1 小时前
单台服务器52块硬盘
服务器
hnxaoli1 小时前
统信小程序(十一)快捷地址栏
linux·python·小程序
黄昏晓x2 小时前
Linux----网络
linux·网络·arm开发
小比特_蓝光2 小时前
Linux开发工具
linux·运维·服务器