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

相关推荐
知已难寻8 小时前
Docker 入门:容器技术与 Docker 基础
java·运维·服务器·docker·云原生·容器
默|笙8 小时前
【Linux网络】网络层协议 IP(1)理解报头、网段划分
linux·网络·tcp/ip
修己xj11 小时前
nslookup 使用指南:两种模式与常用查询技巧
linux
唠玖馆13 小时前
文件系统详解
linux·文件系统·ext2
GeW13 小时前
当Linux内核开始“确定性”,制造高端化才有了底层语法
linux
星恒随风15 小时前
MySQL 从零入门(三):表的约束详解
linux·服务器·数据库·笔记·mysql
Alluxio15 小时前
Alluxio + OCI:为 AI 工作负载实现亚毫秒访问延迟与可扩展吞吐
运维·数据库·人工智能·分布式·缓存·ai·语言模型
StarsGreen17 小时前
libva在intel平台上的前端流程简介
linux
坤坤子吖20 小时前
Linux网络编程:自定义应用层协议与 JSON 序列化
linux·服务器·网络·c++·笔记·json
Sayai20 小时前
Neo4j 图数据质量检查实战:环路检测、孤立节点与连通分量,两条 Cypher 引出的数据体检清单(含变长路径性能陷阱)
运维·neo4j·图数据库·数据质量·cypher