![>>> /etc/sudoers.d/python:第 1 行附近语法错误 < & 基于我在编辑 python 文件中的错误](https://linux22.com/image/1174126/%3E%3E%3E%20%2Fetc%2Fsudoers.d%2Fpython%EF%BC%9A%E7%AC%AC%201%20%E8%A1%8C%E9%99%84%E8%BF%91%E8%AF%AD%E6%B3%95%E9%94%99%E8%AF%AF%20%3C%20%26%20%E5%9F%BA%E4%BA%8E%E6%88%91%E5%9C%A8%E7%BC%96%E8%BE%91%20python%20%E6%96%87%E4%BB%B6%E4%B8%AD%E7%9A%84%E9%94%99%E8%AF%AF.png)
我想以 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 脚本,问题就解决了。