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

相关推荐
KKKlucifer1 小时前
运营商全域安全运维支撑体系落地实践
运维·安全
EAIReport2 小时前
工业电气自动化数据治理破局:多Agent大模型赋能全景智能决策
大数据·运维·自动化
清水迎朝阳2 小时前
客户端软件 — 用户统计方案
服务器·c++·客户端·用户统计
会编程的土豆2 小时前
Go 模板初识
linux·运维·服务器
腾讯蓝鲸智云2 小时前
标杆客户实践提炼:CFlow 版本价值流模板实战指南
运维·服务器·自动化·云计算·devops
阿标的博客3 小时前
Active Directory 组织单位和用户
服务器
Deryck_德瑞克3 小时前
【Nginx】配置差异分析
服务器·前端·nginx
前端 贾公子3 小时前
第06章:结构化输出 (上)
java·服务器·前端
Yang96114 小时前
自动化射频测试台快速搭建,鼎讯信通 DXSL 矢量信号源模块二次开发集成指南
运维·自动化
一只小菜鸡..4 小时前
南京大学 操作系统 (JYY) 学习笔记:持久化的黑魔法——从磁铁、刻坑到闪存电荷
服务器·笔记·学习