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

相关推荐
安全系统学习6 分钟前
网络安全之浅析Java反序列化题目
运维·开发语言·网络·算法·安全·web安全·php
努力学习的小廉1 小时前
深度理解linux系统—— 进程概念
linux·运维·服务器
庐阳寒月1 小时前
GitHub修炼法则:第一次提交代码教学(Liunx系统)
linux·github·嵌入式
夜月yeyue2 小时前
静态库与动态库简介
linux·c++·stm32·单片机·嵌入式硬件
川石课堂软件测试2 小时前
涨薪技术|0到1学会性能测试第44课-apachetop模块监控
服务器·数据库·python·功能测试·性能优化·单元测试
程序员JerrySUN2 小时前
驱动开发硬核特训 │ Day 23(下篇): i.MX8MP LCDIFv3 驱动中的 Regulator 系统全解
linux·驱动开发·嵌入式硬件
我真不会起名字啊2 小时前
每日Bug:(2)共享内存
linux·运维·bug
丰锋ff2 小时前
计算机考研精炼 操作系统
运维·服务器·考研
2401_897930063 小时前
Neo4j 的 `SET n += $properties` 语法详解
linux·服务器·neo4j
zyhhsss3 小时前
curl详解
服务器·网络·笔记