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

相关推荐
拂拉氏13 小时前
【知识讲解】 Linux进程间通信之管道与共享内存
linux·进程间通信
其实防守也摸鱼13 小时前
Linux文本处理命令理论学习
linux·服务器·前端·数据库·sql·学习·安全
无足鸟ICT13 小时前
【RHCA+】rpm命令(安装、升级、卸载和查询)
linux·运维·服务器
吹什么轩13 小时前
linux系统复习:从冯·诺依曼到操作系统:一切的开场
linux·运维·服务器
程序员-Benothing13 小时前
SSH从入门到精通:密钥登录、config配置、跳板机
linux·运维·服务器·ssh
一条泥憨鱼13 小时前
【计算机网络】| 从 MAC 到 NAT 的跨网段通信全链路
服务器·网络·学习·计算机网络·macos
Elastic 中国社区官方博客14 小时前
Jina AI:Elasticsearch 集成
大数据·运维·人工智能·elasticsearch·搜索引擎·全文检索·jina
H.莓飛14 小时前
【Linux】自主 Shell
linux·运维·服务器·c语言·开发语言·visual studio
bigcarp14 小时前
Frida-dexdump 绕过app的Root检测
linux·运维·服务器
ggaofeng14 小时前
linux中的绿色版内存mysql
linux·运维·mysql