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

相关推荐
正仪几秒前
systemd 是什么?
linux·运维·windows
暖核2 分钟前
华为云运维三件套实战:云审计 + 云监控 + 云日志完整操作指南
linux·运维·华为云
网硕互联的小客服3 分钟前
原生IP,住宅IP,ISPIP,机房IP分别都有什么区别?适合用于什么站点或者程序?
服务器·网络·tcp/ip
hhb_6185 分钟前
智能任务自动化协同AI工作流技术文档
运维·人工智能·自动化
AI+程序员在路上33 分钟前
Rv1126b与手机(SPP蓝牙串口APP)蓝牙通信流程
linux·c语言·智能手机
虚无的纽扣40 分钟前
【Linux】进程第二课:进程优先级和环境变量
linux·运维·服务器
maosheng11461 小时前
【无标题】linux中企业容易考的的小知识点1(rhcsa)
linux·运维·服务器
牢姐与蒯1 小时前
Linux进程(九).自定义shell——深度理解命令行和shell
linux·运维·服务器
前端 贾公子1 小时前
Milvus使用指南 (下)
java·服务器·前端
snow@li1 小时前
服务器运维:mysql 安装笔记
运维·服务器·mysql