你有没有遇到过改用户权限结果主用户也获取不了root权限的情况?

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u011636440/article/details/81288265

ubuntu系统,新建一个用户,该用户默认是没有root权限的,安装软件之类的操作很不方便,想更新一下该用户的权限。
编辑/etc/sudoers添加一句jz ALL=(ALL:ALL) ALL(新建用户的用户名是jz)
结果保存后出现

nvidia@tegra-ubuntu:~$ sudo su
/etc/sudoers: syntax error near line 1
sudo: parse error in /etc/sudoers near line 1
sudo: no valid sudoers sources found, quitting
sudo: unable to initialize policy plugin

凉了,主用户也用不了root权限了。
各种需要高权限的操作都没有办法进行了。怎么破?

上面的提示信息已经讲得很清楚了。在/etc/sudoers中第一行有语法错误。也就是说,改文件的时候改错了。

解决办法是
在图形界面的终端内输入命令

pkexec visudo -f /etc/sudoers

把刚刚改错的地方,也就是出现语法错误的地方,改回来。保存退出,(o゜▽゜)o☆[BINGO!]

参考:https://arstechnica.com/civis/viewtopic.php?t=1246553

注意:
一定要在图形界面的终端内操作,用ssh连接后执行相同的命令也会提示没有权限。

nvidia@tegra-ubuntu:~$ pkexec visudo
==== AUTHENTICATING FOR org.freedesktop.policykit.exec ===
Authentication is needed to run `/usr/sbin/visudo’ as the super user
Multiple identities can be used for authentication:
1. ,,, (ubuntu)
2. ,,, (nvidia)
Choose identity to authenticate as (1-2): 1
Password:
polkit-agent-helper-1: pam_authenticate failed: Authentication failure
==== AUTHENTICATION FAILED ===
Error executing command as another user: Not authorized
This incident has been reported.

猜你喜欢

转载自blog.csdn.net/u011636440/article/details/81288265