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

相关推荐
飞飞传输6 分钟前
选对国产FTP服务器,筑牢数据传输安全防线,合规高效双达标
大数据·运维·安全
卷到起飞的数分10 分钟前
22.Maven高级——继承与聚合
服务器·spring boot
西格电力科技17 分钟前
光伏策略控制服务器的核心价值与应用必要性
运维·服务器
拾忆,想起25 分钟前
Dubbo配置方式大全:七种配置任你选,轻松玩转微服务!
服务器·网络·网络协议·微服务·云原生·架构·dubbo
gaize121334 分钟前
服务器的安全性如何保障
服务器·云计算
wdfk_prog1 小时前
[Linux]学习笔记系列 -- [fs]binfmt_script
linux·笔记·学习
GoWjw1 小时前
内存管理【3】
linux·服务器·c++·ubuntu
i橡皮擦1 小时前
使用gamedig 查询恐龙岛TheIsle游戏服务器
运维·服务器·游戏·steam·恐龙岛·the isle
pcc_is_world1 小时前
Nginx HTTPS服务器搭建与认证配置
服务器·nginx·https
White-Legend2 小时前
支持docker一键部署了
运维·docker·容器