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

相关推荐
杭州泽沃电子科技有限公司1 分钟前
在线监测:筑牢风电并网安全与效能的核心防线
运维·在线监测·智能监测·发电
一水鉴天9 分钟前
整体设计 定稿 之6 完整设计文档讨论及定稿 之2 模块化设计体系规范(工具作为首批践行者)(豆包助手)
运维·人工智能·重构·架构
艾莉丝努力练剑10 分钟前
【Python库和代码案例:第一课】Python 标准库与第三方库实战指南:从日期处理到 Excel 操作
java·服务器·开发语言·人工智能·python·pycharm·pip
十月南城13 分钟前
统一日志与链路ID的价值——为什么要结构化日志、如何通过关联ID提升排障效率
运维·网络
huangyuchi.14 分钟前
【Linux网络】UDP协议详解:透过源码看透“面向数据报”与“缓冲区”的本质
linux·网络·udp·报文·linux网络·传输层协议·报头
林九生14 分钟前
【Centos7】CentOS 7 yum源失效解决方案:Could not resolve host mirrorlist.centos.org
linux·运维·centos
福尔摩斯张17 分钟前
【实战】C/C++ 实现 PC 热点(手动开启)+ 手机 UDP 自动发现 + TCP 通信全流程(超详细)
linux·c语言·c++·tcp/ip·算法·智能手机·udp
了一梨20 分钟前
网络编程:UDP Socket
linux·网络协议·udp
xinxinhenmeihao23 分钟前
长效住宅静态IP有什么好处?是选择动态IP还是静态IP好?
服务器·网络·tcp/ip
ChristXlx28 分钟前
Linux安装MongoDB(虚拟机适用)
linux·mongodb·postgresql