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

相关推荐
数字新视界2 小时前
信创动环监控实现机房能耗可视化与用电异常预警
服务器·数据中心·机房·环境管理·环控系统
笔记本note2 小时前
Linux 文件系统与设备文件
linux·服务器·文件系统
无足鸟ICT2 小时前
【RHCA+】_proc_pid_cmdline
linux·运维·服务器
学以智用3 小时前
CentOS Linux 文件操作详解
linux
饿了吃洗衣凝珠4 小时前
shell循环
linux·运维·服务器
代码不停5 小时前
Linux基础知识
java·linux·数据库
木雷坞5 小时前
Docker 镜像源列表(11月30日更新-长期)
运维·docker·容器
feasibility.5 小时前
电脑一天重启3次、WiFi还消失:蓝屏0x9F背后,是MT7921网卡撞上Windows电源管理
服务器·网络·windows·wifi·电脑·网卡·驱动
顧棟5 小时前
INFINI Gateway 启动过程分析
服务器·网络·gateway
东风微鸣6 小时前
Linux台式机也能指纹识别登录验证啦
linux·指纹