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

相关推荐
屁股割了还要学20 分钟前
【Linux入门】常用工具:yum、vim
linux·运维·服务器·c语言·c++·学习·考研
云计算练习生20 分钟前
linux shell编程实战 03 数组:批量处理数据
linux·运维·服务器·数组·shell编程
王道长服务器 | 亚马逊云1 小时前
AWS Elemental MediaConvert:视频转码不再难
linux·服务器·网络·云计算·音视频·aws
Jm_洋洋1 小时前
【Linux系统编程】程序替换:execve(execl、execlp、execle、execv、execvp、execvpe)
linux·运维·c语言·开发语言·程序人生
qq_479875431 小时前
TCP网络编程本质
服务器·网络·tcp/ip
HIT_Weston1 小时前
14、【Ubuntu】【VSCode】VSCode 断联问题分析:hostname(二)
linux·vscode·ubuntu
冲上云霄的Jayden1 小时前
bash执行脚本 CondaError: Run ‘conda init‘ before ‘conda activate‘
linux·ubuntu·conda·bash·init·activate
驱动探索者2 小时前
影石Insta360发展史:从深圳公寓到全球影像创新标杆
linux
Wang's Blog2 小时前
Linux小课堂: SSH 免密登录原理与实现之基于公钥认证的安全连接机制
linux·安全·ssh
戴草帽的大z2 小时前
交叉编译FFmpeg:从x264到RK3588部署实战
linux·ffmpeg·rk3588·h.264·aarch64