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

相关推荐
Neighbor_OldY6 分钟前
【实战复盘】RDP暴力破解与内网横向移动溯源:Windows全套排查命令与事件ID硬核解析
运维·windows·web安全
项目管理实用笔记6 分钟前
CI/CD是什么?持续集成持续交付入门
运维·ci/cd·研发效能·项目管理·团队开发
Sunqk56658 分钟前
将开发板串口连接到Ubuntu后未找到对应的设备文件?
linux·运维·ubuntu
Sophnet云平台10 分钟前
MCP与A2A双协议解析:2026年Agent互操作的技术选型
linux·服务器·网络·上下文·mcp·大模型测评·sophnet
淼澄研学10 分钟前
Debian通过AI决议:合规解析与Ollama本地部署Llama3实操
运维·人工智能·debian
晚风叙码12 分钟前
Linux(二)权限问题
linux·服务器
BI专家之路2 小时前
安装linux/hadoop/jdk/hive
linux·hive·hadoop
GeW15 小时前
超详细!RHCE10版通用备考策略,内含评分细则解读
linux
用户0413284651315 小时前
Linux 服务开机自启动怎么配置?systemctl enable 原理详解
linux
BreezeJiang1 天前
从域名到 Node.js:一次云服务器请求经过了哪些层?
服务器