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

相关推荐
oioihoii16 小时前
数据库查询优化中的谓词下推策略与成本感知优化实践
服务器·数据库·oracle
学习是生活的调味剂16 小时前
大模型应用之使用LangChain实现RAG(二)智能客服
服务器·数据库·langchain
高梦轩16 小时前
LNMP 环境部署笔记
linux·笔记
HAPPY酷16 小时前
Linux `shutdown` 命令速查:安全关机与重启
linux·chrome·安全
zhping101116 小时前
Linux 系统上使用 GitHub 加速工具
linux·运维·github
dreamread16 小时前
Linux下MySQL的简单使用
linux·mysql·adb
YXXY31316 小时前
Linux进程概念(一)
linux
m0_7381207217 小时前
渗透测试——pyexpvm靶机详细提权过程(MSF框架,Hydra数据库爆破,SUDO提权)
服务器·网络·数据库·python·sql·web安全
于眠牧北17 小时前
ubuntu22.04安装docker以及安装过程中报错解决方法
运维·docker·容器
昵称只能一个月修改一次。。。17 小时前
并发服务器、多路IO复用
java·服务器·网络