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

相关推荐
测试修炼手册2 小时前
[测试工具] 用 Codex 做测试实战:从需求分析到自动化用例落地
运维·自动化·需求分析
米高梅狮子2 小时前
03.网络类服务实践
linux·运维·服务器·网络·kubernetes·centos·openstack
June`2 小时前
网络编程时内核究竟做了什么???
linux·服务器·网络
原来是猿2 小时前
腾讯云服务器端口开放完全指南
服务器·网络·腾讯云
你的保护色3 小时前
【无标题】
java·服务器·网络
楼兰公子3 小时前
RK3588 + Linux7.0.3 网络工程调试错误速查手册
linux·网络·3588
Elnaij3 小时前
Linux系统与系统编程(9)——自设计shell与基础IO
linux·服务器
IpdataCloud3 小时前
稳定的企业级IP数据接口怎么选?可用性指标+离线库高可用方案
运维·网络·tcp/ip
WebGIS开发3 小时前
地信职业百科②:GIS运维
运维·gis·就业·转行
淘矿人3 小时前
Claude辅助DevOps实践
java·大数据·运维·人工智能·算法·bug·devops