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

相关推荐
非凡ghost13 小时前
分区助手:Windows 磁盘管理的“瑞士军刀“,分区调整不再怕丢数据
服务器·windows·电脑·软件需求
蓝速科技13 小时前
蓝速科技会议电子门牌规模化部署与运维成本实测
运维·科技
许彰午13 小时前
# allbytaskid——一个接口扛六个DataStore
运维·服务器·php
吠品13 小时前
Java byte数组与String互转:编码细节与踩坑记录
java·linux·服务器
牛奶咖啡1313 小时前
AI助力运维——AIGC运维应用实践—Deepseek的介绍与本地部署选型
运维·人工智能·deepseek·deepseek能做什么·deepseek本地部署配置·本地部署选型避坑原则·本地部署的典型方案
木白CPP14 小时前
Linux 驱动UART子系统源码分析
linux·运维·服务器·驱动开发·嵌入式硬件·开源软件
-今昭-14 小时前
HAProxy 负载均衡部署
运维·负载均衡
RisunJan14 小时前
Linux命令-times(进程累计时间显示)
linux·运维·chrome
xiaoxiangsiyan15 小时前
RHCE2026完整版全知识点清单
运维·网络·学习·自动化·rhce
风控PM说15 小时前
自动化风控策略生成:基于决策树的方法
运维·决策树·自动化