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

相关推荐
我命由我123456 分钟前
Python 开发 - Python 虚拟环境
运维·开发语言·后端·python·http·https·java-ee
dlhto15 分钟前
Windows 使用 Rufus 制作 AlmaLinux 10.2 启动 U 盘:从 ISO 下载到服务器安装
运维·服务器·windows
一直C17 分钟前
嵌入式 Linux 驱动开发学习笔记:内核定时器、platform 总线与 I²C 驱动
linux·驱动开发·嵌入式硬件·学习·imx6ull
软件派19 分钟前
Beam.Win 自动化办公与业务流程提效指南
运维·自动化
承渊政道42 分钟前
Linux网络学习【传输层协议UDP】
linux·网络·网络协议·学习·ubuntu·udp
雯宝1 小时前
usb_serial_init/tty_driver/alloc_tty_driver/tty_register_driver/usb_register
linux
澜山奕秋1 小时前
Rhcsa 二
linux·运维·服务器
小此方1 小时前
Linux网络(三十三):告别O(n)噩梦:从select/poll的挣扎到epoll红黑树+回调的降维打击,一文打通IO多路复用
linux·网络·驱动开发
2301_777998341 小时前
Linux 网络:数据链路层
linux·服务器·网络
迷途之人不知返1 小时前
【文件系统】-1-磁盘与扇区的定位方法
linux