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

相关推荐
nj01284 小时前
Linux 根分区占满排查与 SSH 暴力破解日志清理记录
linux·运维·ssh
xingfujie4 小时前
第2章:服务器规划与基础环境配置
linux·运维·微服务·云原生·容器·kubernetes·负载均衡
shizhan_cloud4 小时前
华为云核心服务运维知识点与高频实操问题总结
运维·华为云
l1t4 小时前
DeepSeek总结的Quack:DuckDB 客户端-服务器协议(二)
运维·服务器·duckdb
xugyw4 小时前
window获取安全码SHA1、SHA256和jks文件
运维·服务器·安全
肖爱Kun4 小时前
Webrtc信令交互
服务器·webrtc
杨浦老苏4 小时前
开源服务器监控工具Checkmate
运维·docker·群晖·网站监控
yyyyy_abc4 小时前
docker学习笔记
运维·docker·容器
2301_780789664 小时前
多层级 CC 防护体系:前端验证与后端限流的协同配置实践
运维·服务器·前端·网络安全·智能路由器·状态模式
秋94 小时前
Windows 环境下 Redis 部署详解:从选型、安装到生产级配置与运维
运维·windows·redis