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

相关推荐
T1mzhou19 分钟前
ARM64 Linux 6.10内核启动流程7-ioremap和readl writel
linux·服务器·c语言
小羊没烦恼!35 分钟前
Hello Web API系列教程——Web API与国际化
java·服务器·前端·javascript·php
Elastic 中国社区官方博客36 分钟前
教程:使用 ES|QL 进行威胁狩猎
大数据·运维·数据库·elasticsearch·搜索引擎·全文检索·安全威胁分析
bwz999@88.com1 小时前
Ubuntu Server 24.04 设置中文
linux·运维·ubuntu
fly-971 小时前
Ubuntu FTP/SFTP 报错:找不到匹配的 hostkey 算法 完整解决
linux·ubuntu
Cx330❀2 小时前
【Linux网络】网络层协议 IP :从网络层原理到 Linux 内核源码
linux·运维·服务器·网络·tcp/ip·ai·ai编程
志栋智能2 小时前
运维超自动化的变更管理实践
运维·自动化
全栈攻略2 小时前
Docker 中 ROS2 工作流 Topic 验证与常用命令指南
运维·docker·容器
Gl�ria2 小时前
Linux 清理日志常用命令
linux·运维·服务器