Can't use sudo
The following errors are giving when trying to use sudo.
sudo: parse error in /etc/sudoers.d/my_sudoers near line 4
sudo: no valid sudoers sources found, quitting
sudo: unable to initialize policy plugin
I know exactly what is wrong but I have no way to edit the file since it is owned by root.
I can't use chown to change the ownership because that would involve using sudo.
Pkexec has not been installed or configured on the server so I'm not sure if that is an option.
I have tried using the copy command to make a back up but I get the same errors.
Can someone please tell me how to solve this?
Please don't recommend reboot the server because that is not an option.
3 Replies
@LowerMedia:
After I edited the /etc/sudoer.d/my_sudoers file with nano I was unable to use sudo.
The following errors are giving when trying to use sudo.
sudo: parse error in /etc/sudoers.d/my_sudoers near line 4 sudo: no valid sudoers sources found, quitting sudo: unable to initialize policy plugin
I know exactly what is wrong but I have no way to edit the file since it is owned by root.
I can't use chown to change the ownership because that would involve using sudo.
Pkexec has not been installed or configured on the server so I'm not sure if that is an option.
I have tried using the copy command to make a back up but I get the same errors.
Can someone please tell me how to solve this?
Please don't recommend reboot the server because that is not an option.
Switch to the root user with 'su' and type its password. Or open a SSH connection directly to root. Or use LiSH to directly open a root shell.
If none of these options are viable, I would suggest deleting the /etc/sudoers.d/my_sudoers file via recovery (Finnix)
By the way, I don't know about your distro, but mine says this at the top of /etc/sudoers:
> #
This file MUST be edited with the 'visudo' command as root.
This is why.
Thank you so much for the help