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 小时前
9-Linux驱动开发-设备树=>设备树插件实现 RGB 灯驱动
linux·驱动开发·stm32·嵌入式硬件
叫致寒吧2 小时前
Nginx基于域名的虚拟主机实操案例
运维·服务器·nginx
施努卡机器视觉3 小时前
SNK施努卡车门自动化安装
运维·自动化
梁正雄3 小时前
linux服务-Nginx+Tomcat+Redis之Session 共享 - 容器compose
linux·nginx·tomcat
咕噜签名-铁蛋3 小时前
云服务器与物理服务器、VPS的区别
运维·服务器
恒创科技HK3 小时前
香港服务器流量有限制和带宽有限制区别在哪?
运维·服务器·网络
fengyehongWorld3 小时前
Linux rsync命令
linux
wanhengidc3 小时前
机架式服务器有什么作用?
运维·服务器·web安全·智能手机·云计算
干啥都是小小白4 小时前
Linux C编程
linux·运维·服务器
赖small强4 小时前
【Linux 网络基础】WebSockets 技术指南
linux·网络·https·websockets·ping/pong