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

相关推荐
java_logo几秒前
Milvus GUI ATTU Docker 容器化部署指南
运维·数据库·docker·容器·eureka·milvus
盛满暮色 风止何安5 分钟前
负责均衡的理解
运维·服务器·网络·网络协议·系统安全·安全架构
wyjcxyyy19 分钟前
2025polar冬季赛复盘(WEB,MISC)
运维·服务器
HealthScience27 分钟前
vscode通过跳板机连接到服务器
服务器·ide·vscode
知识分享小能手30 分钟前
CentOS Stream 9入门学习教程,从入门到精通,CentOS Stream 9 进程管理 —语法详解与实战案例(8)
linux·学习·centos
翔云12345630 分钟前
服务器异常崩溃,GTID 是否会出现在 mysql.gtid_executed 表但不在 binlog 中
服务器·mysql·adb
零日失眠者30 分钟前
⚠️ 警告!99%的开发者都踩过这个坑:Python3安装后系统彻底瘫痪!yum直接报废的真相
linux·python
寒山李白31 分钟前
关于supervisor-win的安装、配置和使用
服务器·python·supervisor
Bigan(安)32 分钟前
【奶茶Beta专项】【LVGL9.4源码分析】04-OS抽象层
linux·c语言·mcu·arm·unix
Bigan(安)34 分钟前
【奶茶Beta专项】【LVGL9.4源码分析】06-tick时间管理
linux·c语言·mcu·arm·unix