>>> /etc/sudoers.d/python:第 1 行附近语法错误 < & 基于我在编辑 python 文件中的错误

>>> /etc/sudoers.d/python:第 1 行附近语法错误 < & 基于我在编辑 python 文件中的错误

我想以 root 身份运行 pycharm指导和,但是我犯了错误,没有:在这个脚本中添加: user host = (root) NOPASSWD: full_path_to_python/etc/sudoers.d/python文件里。

所以现在我无法再编辑它了,说明和更多来自互联网的内容,如您在下面所见(此外,我还更改了管理员用户密码并忘记了以前的密码,所以现在我无法使用su root!):


so@so-notebook:/etc/sudoers.d$ sudo gedit python
>>> /etc/sudoers.d/python: syntax error near line 1 <<<
sudo: parse error in /etc/sudoers.d/python near line 1
sudo: no valid sudoers sources found, quitting
sudo: unable to initialize policy plugin
so@so-notebook:/etc/sudoers.d$ su so
Password: 
so@so-notebook:/etc/sudoers.d$ sudo gedit
>>> /etc/sudoers.d/python: syntax error near line 1 <<<
sudo: parse error in /etc/sudoers.d/python near line 1
sudo: no valid sudoers sources found, quitting
sudo: unable to initialize policy plugin
so@so-notebook:/etc/sudoers.d$ nano
Use "fg" to return to nano.

[3]+  Stopped                 nano
so@so-notebook:/etc/sudoers.d$ sudo nano python
>>> /etc/sudoers.d/python: syntax error near line 1 <<<
sudo: parse error in /etc/sudoers.d/python near line 1
sudo: no valid sudoers sources found, quitting
sudo: unable to initialize policy plugin
so@so-notebook:/etc/sudoers.d$ sudo visudo -f python
>>> /etc/sudoers.d/python: syntax error near line 1 <<<
sudo: parse error in /etc/sudoers.d/python near line 1
sudo: no valid sudoers sources found, quitting
sudo: unable to initialize policy plugin
so@so-notebook:/etc/sudoers.d$ su root
Password: 
su: Authentication failure
so@so-notebook:/etc/sudoers.d$ sudo -i  
>>> /etc/sudoers.d/python: syntax error near line 1 <<<
sudo: parse error in /etc/sudoers.d/python near line 1
sudo: no valid sudoers sources found, quitting
sudo: unable to initialize policy plugin
so@so-notebook:/etc/sudoers.d$ 
so@so-notebook:/etc/sudoers.d$ sudo bash
>>> /etc/sudoers.d/python: syntax error near line 1 <<<
sudo: parse error in /etc/sudoers.d/python near line 1
sudo: no valid sudoers sources found, quitting
sudo: unable to initialize policy plugin
so@so-notebook:/etc/sudoers.d$ sudo -s
>>> /etc/sudoers.d/python: syntax error near line 1 <<<
sudo: parse error in /etc/sudoers.d/python near line 1
sudo: no valid sudoers sources found, quitting
sudo: unable to initialize policy plugin
so@so-notebook:/etc/sudoers.d$ sudo apt-get update
>>> /etc/sudoers.d/python: syntax error near line 1 <<<
sudo: parse error in /etc/sudoers.d/python near line 1
sudo: no valid sudoers sources found, quitting
sudo: unable to initialize policy plugin
so@so-notebook:/etc/sudoers.d$ 
so@so-notebook:/etc/sudoers.d$ sudo apt-get update
>>> /etc/sudoers.d/python: syntax error near line 1 <<<
sudo: parse error in /etc/sudoers.d/python near line 1
sudo: no valid sudoers sources found, quitting
sudo: unable to initialize policy plugin

我的操作系统版本是:

so@so-notebook:~/Desktop/trash/s$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.4 LTS
Release:    18.04
Codename:   bionic

谢谢。

答案1

我进入 python 文件夹并尝试:

so@so-notebook:/etc/sudoers.d$ sudo visudo -f python

正如您在问题中看到的,但我重申并尝试:

pkexec visudo -f /etc/sudoers.d/python这里,并添加:python 脚本,问题就解决了。

相关内容