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

相关推荐
欲买桂花同载酒5825 小时前
程序人生-Hello’s P2P
运维·服务器·数据库
八月的雨季 最後的冰吻5 小时前
FFmepg-- 38-Jitter Buffer固定值c程序分析
服务器·音视频
NineData5 小时前
AI时代的数据对比:DBA还需要盯着屏幕看差异吗?
运维·数据库
jyfool5 小时前
Ubuntu 远程桌面配置踩坑实录:从 TightVNC 到 x11vnc 的折腾之旅
linux·运维·ubuntu
网硕互联的小客服5 小时前
服务器防火墙是如何区分正常流量和攻击流量?
运维·服务器·网络
安当加密5 小时前
基于 RADIUS 的 Linux 服务器双因子认证:从 FreeRADIUS 到轻量级 ASP 方案的演进
linux·运维·服务器
66清小风6 小时前
服务器安装操作系统报X or window manager startup failed, falling back to mode
linux·kylin
A-刘晨阳6 小时前
【Prometheus】Alertmanager配置钉钉告警
运维·云原生·钉钉·prometheus·监控
西西学代码6 小时前
Flutter---路由与导航
服务器·前端·javascript
wangqiaowq6 小时前
llama.cpp 启动命令优化
运维·服务器