Original address
When using Ubuntu, we often use the sudo command. However, when using Ubuntu users to log in and use the sudo command, we often need to enter a password. For convenience, we may modify the/etc/sudors file under the root user so that the sudo command does not need to enter a password. At this time, it is inevitable to enter an error, resulting in the sudo command not being used, An error similar to the following appears
>>> /etc/sudoers: syntax error near line 31 <<<
sudo: parse error in /etc/sudoers near line 31
sudo: no valid sudoers sources found, quitting
sudo: unable to initialize policy plugin
Sudo doesn’t work. Under Ubuntu, you usually don’t set the root password, so you can’t enter the root user at all.
At this time, the normal way is to restart the system, enter grub interface, then enter recovery mode, modify sudors file, and restart the system.
But sometimes, the host is not controlled by itself, and only has the permission of SSH login system.
At this time, the following method is the Savior:
Use the following command to edit the sudoers file
pkexec visudo
However, the following errors were reported:
==== AUTHENTICATING FOR org.freedesktop.policykit.exec ===
Authentication is needed to run `/usr/sbin/visudo' as the super user
Authenticating as: ceshi,,, (ceshi)
Password:
polkit-agent-helper-1: error response to PolicyKit daemon: GDBus.Error:org.freedesktop.PolicyKit1.Error.Failed: No session for cookie
==== AUTHENTICATION FAILED ===
Error executing command as another user: Not authorized
This incident has been reported.
What should I do?What’s the problem?I don’t know. The correct opening mode is as follows:
1. Open the two SSH terminals and log in with the Ubuntu user
2. Enter the following command at the first terminal to get PID
echo $$
3. At the second terminal, enter:
pkttyagent --process {pid}
Here {PID} is the PID value obtained in the second part (PS: remember to remove {})
4. At this time, the second terminal will be stuck, and input the following at the first terminal:
pkexec visudo
5. Then, the second terminal is also the card owner. When you return to the first terminal, you will be prompted to enter the current user password and enter the
6. OK, after inputting the password, the first terminal card is owned. When you go back to the second terminal, you will find that the content of sudoers appears. If there is any editing error, just save it.
7. Complete the task, modify it, and find that you can continue to use the sudo command, over
PS: the editor used here is nano. Here is a simple way to save nano:
To exit in edit mode under Linux, press Ctrl + X, there are two situations:
① if the file is not modified, exit directly
Read More:
- Sudo: parse error in / etc / sudoers near line 24
- (Caused by SSLError(SSLError(1, ‘[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1123)‘)))
- Solutions to the problem that Ubuntu is stuck when copying large files and can’t mount mobile hard disk normally
- Solutions to the problem of vulnerable missing firmware in Ubuntu
- Authentication token manipulation error appears in ubuntu18.04 password modification
- Caused by: java.net.SocketException : connection reset or caused by: java.sql.SQLRecoverableException solve
- Git authentication failure solution, due to the problem of password modification
- Two kinds of errors caused by root / lack of execution permission x
- Solve the problem caused by: java.sql.SQLRecoverableException : IO error: connection reset related problems
- The solution to the error of / etc / sudoers: syntax error in sudoer file under mac
- The problem of master-slave database synchronization stop caused by MySQL deleting data
- Mobaxterm connects to Ubuntu server through SSH network error: software caused connection abort
- Failed to load SELinux policy. Freezing due to modification of SELinux by centos7
- Ubuntu “a user name is not in the sudoer folder. It will be reported. ” Solutions for
- Solutions to network connection problems in Ubuntu 16.04.3
- How to Fix ”is not in the sudoers file“ in Linux
- Brief introduction of idea Lombok and solutions for reporting red and wrong
- Problems and solutions of installing Ubuntu 12.04 in win7
- “Failed to load session” Ubuntu “problem solving summary
- Exception on start hive: caused by: java.net.noroutetohostexception: no route to host