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

相关推荐
生活爱好者!3 分钟前
效率高!开源协作 Wiki 与文档管理平台 NAS一键部署docmost
运维·网络·docker·容器·开源
间彧12 分钟前
tail 、journalctl 、 docker logs -f命令详解
linux
西西学代码1 小时前
Flutter---Listview横向滚动列表(2)
linux·运维·flutter
翼龙云_cloud1 小时前
阿里云渠道商:WordPress网站如何使用文件存储NAS?
运维·服务器·阿里云·云计算
鸡蛋炒肉1 小时前
radius服务器创建方法
服务器·radius
2401_837088502 小时前
在 IDEA 中启动同一个项目的两个实例,让idea底层配置两个Tomcat 服务器
java·服务器·intellij-idea
桃花岛主702 小时前
multipart/form-data 和 application/x-www-form-urlencoded区别
服务器·网络·网络协议·http
q***T5832 小时前
Docker文本处理开发
运维·docker·容器
biubiubiu07062 小时前
给Docker设置代理
运维·docker·容器
h***83932 小时前
Docker测试框架使用指南
运维·docker·容器