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

相关推荐
拾光Ծ2 小时前
【Linux网络】计算机网络入门:网络产生与协议
linux·网络·网络协议·tcp/ip·计算机网络
稳联技术老娜8 小时前
DeviceNet主站怎么连接西门子PLC,Profinet网关配置手册(那智机器人)
服务器·网络·数据库
三十..9 小时前
Ceph 三大存储接口深度实践与数据保护指南
运维·ceph
9分钟带帽9 小时前
linux_系统开机自动执行shell脚本
linux·服务器
蝶豆花10 小时前
基于商城系统的功能,自动化,性能-测试报告
运维·自动化
袋鼠云数栈10 小时前
从前端到基础设施,ACOS 如何打通企业全链路可观测
运维·前端·人工智能·数据治理·数据智能
黎阳之光10 小时前
视频孪生智护供水生命线:黎阳之光赋能医疗与园区水务高质量升级
运维·物联网·算法·安全·数字孪生
消失在人海中10 小时前
oracle 数据库多表关联查询
服务器·数据库·oracle
志栋智能10 小时前
AI驱动无代码:降低巡检超自动化的门槛
大数据·运维·网络·人工智能·自动化
嵌入式小能手11 小时前
飞凌嵌入式ElfBoard-进程间的通信之命名管道
linux·服务器·算法