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

相关推荐
想做小南娘,发现自己是女生喵28 分钟前
第三周学习文档 Linux C 多进程与多线程
linux·c语言·学习
吴声子夜歌43 分钟前
Docker入门与实战——实战案例(编程开发)(一)
运维·docker·容器
空空dream43 分钟前
04 | 用 Jenkins 打通 CI自动构建镜像并推送到本地 Harbor
运维·ci/cd·jenkins
海宇AI1 小时前
零信任架构实战:基于海宇运营商近3个月平均账单构建自动化免押租赁授信网关
运维·人工智能·架构·自动化
此生决int1 小时前
Linux系列(06)——进程概念(上)
linux·运维·服务器
海宇服务1 小时前
零信任架构实战:基于海宇股权穿透构建自动化招投标供应商关联排查网关
运维·人工智能·架构·自动化
房开民1 小时前
通俗总结 Octree(八叉树)
java·服务器·数据库
wdfk_prog2 小时前
LWIP教程 13:从 `dhcp_start()` 到 `DHCP_STATE_BOUND`——DHCPv4、ACD、Timer 与真实抓包
运维·网络协议
星云低代码开发平台2 小时前
AI 连接器运行健康度:指标、异常恢复和联调清单
大数据·运维·网络·数据库·人工智能·mcp
Sayai2 小时前
Hadoop 集群安全加固实战:YARN 未授权访问漏洞修复,firewalld 白名单 + Nginx 反向代理 Basic Auth 全流程
运维·hadoop·nginx·安全·网络安全