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

相关推荐
KuaCpp1 天前
Linux从0到1学习
linux·学习
优化Henry1 天前
新建LTE站点光功率劣化分析与处理案例
运维·网络·5g·信息与通信
志栋智能1 天前
运维超自动化的本质:效率、质量与创新的三重奏
运维·服务器·数据库·安全·自动化
y小花1 天前
安卓vold服务
android·linux·运维
开开心心就好1 天前
体积小巧的图片重复查找工具推荐
linux·运维·服务器·智能手机·自动化·excel·fabric
tryqaaa_1 天前
学习日志(一)【含markdown语法,Linux学习】
linux·运维·学习·web安全·web·markdown
渔民小镇1 天前
5 分钟搭建桌游服务器:Room 模块 + 领域事件实战
java·运维·服务器·分布式·游戏
小义_1 天前
【Kubernetes】(七) 控制器2
linux·运维·云原生·kubernetes·红帽
WJ.Polar1 天前
Ansible任务控制
linux·运维·网络·python·ansible
计算机安禾1 天前
【Linux从入门到精通】第10篇:软件包管理——Linux如何安装与卸载软件
java·linux·运维·服务器·编辑器