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

相关推荐
青禾8378 小时前
Linux 操作系统入门指南:从目录结构到常用命令
linux·运维·服务器
zhengqweasd8 小时前
流量没跑满、带宽空闲,业务依然卡顿
运维·服务器·网络
闖649 小时前
入门Linux操作系统|零基础吃透原理、目录、权限、常用命令
linux
bruk_spp9 小时前
linux pinctrl
linux
M哥支付10 小时前
高频交易优选方案:银联快捷支付通道
服务器·网络·其他·微信·金融
Y38153266210 小时前
Docker Compose 服务依赖与健康检查:healthcheck 让容器按正确顺序启动
运维·docker·容器
稳联技术老娜10 小时前
伺服内嵌EtherNet IP方案:嵌入式小板SPI通讯固件Demo程序适配改造
运维·服务器·网络
en.en..11 小时前
Linux系统编程:fcntl 与 ioctl
linux·运维·服务器
自动化监测Learner11 小时前
Navicat Premium 17 中文版安装教程(2026最新版)
java·linux·数据库
荣合技术服务12 小时前
Codex 实战:用 AI 写运维脚本
运维·codex