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

相关推荐
Ares-Wang1 小时前
Linux》》systemd 、service、systemctl daemon-reload、systemctl restart docker
linux·运维·docker
安审若无3 小时前
运维知识框架
运维·服务器
阿拉斯攀登3 小时前
从入门到实战:CMake 与 Android JNI/NDK 开发全解析
android·linux·c++·yolo·cmake
Arvin6276 小时前
Nginx 添加账号密码访问验证
运维·服务器·nginx
风曦Kisaki6 小时前
# Linux 磁盘查看命令详解:df 与 du
linux·运维·网络
路溪非溪6 小时前
Linux中gpio子系统的现代接口
linux·arm开发·驱动开发
攻城狮在此6 小时前
华为交换机Console口密码如何清除
运维·网络·华为
内心的一片海7 小时前
服务器内存异常占用
运维·服务器
文静小土豆7 小时前
Centos7负载异常过高排查思路(Load Average)
linux
Deitymoon7 小时前
linux——原子操作
linux