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

相关推荐
码农阿豪2 分钟前
Prometheus怎么监控另一台Linux服务器?Node Exporter配置教程
linux·服务器·prometheus
三言老师9 分钟前
CentOS7 / 8 yum 查询软件安装路径实操
运维·服务器·网络·centos
BullSmall14 分钟前
Jenkins LTS JDK21 docker-compose.yml(生产可用)
运维·docker·jenkins
公众号:fuwuqiBMC15 分钟前
(转自“服务器BMC”)服务器BMC芯片功能——LTPI简介
运维·服务器
倚栏听雨_ylty26 分钟前
H3C交换机关闭Telnet和HTTP服务实例
运维·网络·tcp/ip·网络安全
念何架构之路29 分钟前
docker-Builder镜像构建
运维·docker·容器
xywww16832 分钟前
Claude Opus 5 API 接入实战:国内项目上线前的网络、Key、限流和排错清单
大数据·linux·网络·数据库·云计算·aws
ShineWinsu35 分钟前
对于Linux:http的解析
linux·网络·c++·网络协议·http·请求·响应
易筋紫容38 分钟前
为什么做了 DevOps,你还是管不好开源依赖?
运维·开源·devops
强里秋千墙外道42 分钟前
Ubuntu 开机 Kernel Panic:HWE 内核升级失败 + NVIDIA DKMS 踩坑实录
linux·运维·ubuntu