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

相关推荐
Better Bench14 分钟前
Ubuntu aarch64 (arm64)架构开发板的Linux系统安装拼音输入法
linux·ubuntu·arm64·aarch64·拼音输入法
测试人社区-千羽18 分钟前
智能测试的终极形态:从自动化到自主化的范式变革
运维·人工智能·python·opencv·测试工具·自动化·开源软件
秋刀鱼 ..21 分钟前
2026年机器人感知与智能控制国际学术会议(RPIC 2026)
运维·人工智能·科技·金融·机器人·自动化
roman_日积跬步-终至千里28 分钟前
【源码分析】StarRocks 跨集群数据迁移工具 - 基于快照进行的快速迁移
运维
koddnty33 分钟前
在c++中使用HOOK修改sleep函数
linux·c++
Jovin Giogic35 分钟前
简明教程:记录 Ubuntu系统命令行安装TexLive,配置vscode
linux·vscode·ubuntu·latex·texlive
猫豆~42 分钟前
Shell脚本部署——8day
linux·云计算
屿行屿行42 分钟前
【Linux】浅析Linux内存管理机制
linux
潘晓可1 小时前
Docker部署Bookstack
运维·docker·容器
Serverless社区1 小时前
阿里云新发的AgentRun 有哪些“大招”,一文详解来了
运维·阿里云·云原生·serverless