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

相关推荐
C++ 老炮儿的技术栈2 分钟前
有符号变量与无符号变量的区别
服务器·开发语言·前端·数据结构·c++·算法·c
IT大白鼠7 分钟前
搜索系列 · 第 04 篇——部署实操:内网集群落地
运维·elasticsearch·nosql
Elastic 中国社区官方博客22 分钟前
使用 Jev 作为 search reranker:基准测试与实现方法
大数据·运维·elasticsearch·全文检索
YYRAN_ZZU25 分钟前
如何编一个gcc的交叉工具链
linux·c++
shjita38 分钟前
centos中安装docker
linux·docker·centos
红红谈说1 小时前
浏览器自动化环境老是起不来?依赖治理与启动自检的一次复盘
运维·自动化·浏览器自动化·进程残留·环境依赖·启动自检·版本比较
程序猿老A1 小时前
阿里云linux服务器安装mysql并实现远程访问
linux·服务器·阿里云
wuminyu1 小时前
JVM虚拟线程的底层实现原理分析
java·linux·c语言·jvm·c++
M78佐菲1 小时前
ARM学习笔记(9)
linux·arm开发·笔记·嵌入式硬件·学习
赵民勇1 小时前
glib-compile-schemas命令详解
linux·运维