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

相关推荐
迈威通信25 分钟前
MICF600S-2F工业CAN光纤转换器技术解析:光纤远传、环网自愈与云边协议互通
运维·网络·架构·信息与通信
EmbeddedChen3 小时前
Linux Shell 脚本入门:写一个自动备份文件的小工具
linux·bash·shell
志栋智能3 小时前
超自动化安全的报告自动生成与分发
运维·安全·自动化
智购科技无人售货机工厂店4 小时前
自动售货机刷脸支付集成实战:活体检测与合规门槛~YH
java·服务器·前端·科技·零售
开开心心就好5 小时前
定时结束进程的小工具,到点还能关机
linux·运维·服务器·智能手机·pdf·电脑·word
风翼靓崽5 小时前
ansible
linux·运维·ansible
遨游DATA6 小时前
容器退出码 126 排查:静态资源镜像层如何改写目录权限
linux·docker·kubernetes·文件权限
其实防守也摸鱼6 小时前
Day 3 · Agent Loop:从调用模型到控制循环 —— 课件精讲笔记
服务器·开发语言·javascript·数据库·人工智能·笔记·ecmascript
笔记本note6 小时前
Linux 定时器与时间管理
linux·时间·定时器
NPE~7 小时前
.sock 文件入门:从“文件路标”到进程间通信
linux·macos·教程·基础知识·.sock