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

相关推荐
尤老师FPGA4 小时前
petalinux修改设备树添加vdma生成linux系统
android·linux·运维
yxy___4 小时前
达梦分布式集群DPC_重做副本-操作指南(DEM)_yxy
运维·分布式
月山知了4 小时前
linux kernel component子系统:基于rk3588 Android 14 kernel-6.1 display-subsystem代码分析
android·linux·运维
_Emma_4 小时前
【QCOM】 Linux下qcom venus 编解码驱动框架分析
linux·驱动开发·视频编解码
星辰徐哥5 小时前
大模型工程化部署:Docker Compose批量部署
运维·docker·容器
SEO-狼术5 小时前
Support Network Diagnostics in .NET
运维·服务器·网络
AI周红伟5 小时前
AI自动盯盘与定时行情分析:OpenClaw股票辅助Agent集成完整使用指南-周红伟
运维·服务器·人工智能·音视频·火山引擎
不才小强5 小时前
Linux系统常用命令
linux·运维·网络
SPC的存折6 小时前
8、Ansible之Playbook---Roles
linux·服务器·ansible
Kira Skyler6 小时前
BPF KPROBE编程中的ctx是什么?
linux