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

相关推荐
春日见7 小时前
如何入门端到端自动驾驶?
linux·人工智能·算法·机器学习·自动驾驶
dys_Codemonkey7 小时前
如何在树莓派上用 VS Code 优雅直连内部的 Ubuntu 子系统/容器用来访问容器内的文件和代码?
linux·运维·ubuntu·树莓派
炸膛坦客7 小时前
Linux - Ubuntu - PC端:(五)shell 操作(终端命令,2026)→ 3)基础命令,27 个常用命令
linux·ubuntu
·醉挽清风·8 小时前
学习笔记—Linux—文件IO
linux·服务器·学习
宁波阿成8 小时前
OpenClaw 在 Ubuntu 22.04.5 LTS 上的安装与问题处理记录
java·linux·ubuntu·openclaw·龙虾
上海合宙LuatOS8 小时前
LuatOS核心库API——【 string】字符串操作
运维·服务器·物联网·junit·硬件工程·信息与通信·嵌入式实时数据库
徐子元竟然被占了!!8 小时前
Linux的cat
linux·运维·服务器
带娃的IT创业者8 小时前
WeClaw 离线消息队列实战:异步任务队列如何保证在服务器宕机时不丢失任何一条 AI 回复?
运维·服务器·人工智能·python·websocket·fastapi·实时通信
kc胡聪聪9 小时前
nginx的性能优化与监控
运维·nginx·性能优化
上海合宙LuatOS9 小时前
LuatOS核心库API——【sys】LuatOS运行框架
运维·服务器·物联网·硬件工程·lua·软件工程·信息与通信