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

相关推荐
Darkwanderor1 分钟前
Linux系统编程实战项目:模拟实现shell
linux·c++
便利店102433 分钟前
TCP 为什么有时故意跑不快?拥塞控制与滑动窗口一次讲清
服务器·网络协议·tcp·拥塞控制
杨某不才2 小时前
如何能让Linux服务器对shell 终端 + sftp 文件传输长期保活
linux·运维·服务器
vance042 小时前
免费Cloudflare隧道隐藏公网IP
linux·tcp/ip·github
三言老师3 小时前
文本工具组合统计服务器日志数据
linux·运维·服务器
m0_743697593 小时前
DNS服务器
运维·服务器
mounter6253 小时前
认识 Tetragon:基于 eBPF 的安全监控与强制执行工具
linux·ebpf·cve·kernel
aixingkong9215 小时前
AI超节点Scale Up域总线各层优化设计
linux·服务器·网络
kidwjb5 小时前
Linux内核-文件系统-文件系统目录和文件操作
linux·内核·文件系统
yj_xqj5 小时前
Docker 基础应用与介绍
运维·docker·容器