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

相关推荐
天远API4 小时前
零信任架构实战:基于天远运营商三要素详版V即时版构建自动化消费电子大促电商平台高价值权益秒杀与优惠券防羊毛高并发实名核验网关
运维·人工智能·架构·自动化
Android系统攻城狮4 小时前
Linux FFmpeg深度解析之avcodec_default_get_encode_buffer调用流程与实战(二十八)
linux·运维·服务器·ffmpeg·车载音视频·ffmpeg音视频
程序员初一4 小时前
8080 打不开的四层定位:监听地址、ufw、DOCKER 链、安全组
linux·ssh
程序开发阿元5 小时前
swappiness 60 和 10 差在哪:一台 1C1G 的三轮对比
linux·ssh
无足鸟ICT5 小时前
【RHCA+】mpstat命令(监控CPU)
linux
乐维_lwops5 小时前
案例解读:大型综合性科创产业园运维监控落地实践
运维·网络·人工智能·安全·it监控·国产运维智能体
GeW6 小时前
新质生产力Linux和数据库为啥这么关键
linux
番茄啊7 小时前
linux 开启xftp连接
linux·运维·服务器
CodeYp20197 小时前
第1讲:Linux 基础指令
linux·指令
IT利刃出鞘7 小时前
Docker Compose--解决修改配置后不生效的问题
运维·docker·容器