Scenario:
While trying to execute sudo -s have you encountered the below error message. Also are you unable to open sudoers file to edit and fix it.
ubuntu@digi:$ sudo -s >>> /etc/sudoers: syntax error near line 21 <<< sudo: parse error in /etc/sudoers near line 21 sudo: no valid sudoers sources found, quitting sudo: unable to initialize policy plugin
Let's fix this error without booting into single-user mode.
To fix broken sudoers file or corrupted sudoers file and don’t require rebooting using a live CD, or physical access to the machine.
Solution: Fix broken sudoers file
ubuntu@rootadminz:$ pkexec vim /etc/sudoers Authentication is needed to run `/usr/bin/vim' as the super user Authenticating as: Ubuntu (ubuntu) Password:
It would prompt for the password. Authenticate yourself with the password for the user you are trying to authenticate and then it will open /etc/sudoersfile in your favourite editor (in my case vim) as root, and you can fix your /etc/sudoers file.
Done!