7

I am new to Ubuntu. And as while editing anything in visual studio code, I had to enter password. so for that I tried to change in sudoers file but after that I am unable to find what happened and also getting error like below.

I used the command to change i

sudo nano -w /etc/sudoers

after which i pressed ctrl+x

/etc/sudoers: syntax error near line 26 <<<
sudo: parse error in /etc/sudoers near line 26
sudo: no valid sudoers sources found, quitting
sudo: unable to initialize policy plugin

Thank you.

James Z
  • 12,209
  • 10
  • 24
  • 44
Dcoder14
  • 1,831
  • 3
  • 12
  • 22

3 Answers3

8

Edit:

On your terminal type:

pkexec nano /etc/sudoers

It will open the file and you can edit now. To save and exit the file, just press:

Ctrl+X

And it will ask you if you wanna save the file. So type: Y and Enter. Done!!!

Scott
  • 4,974
  • 6
  • 35
  • 62
  • I am not getting you. can u plz tell me what is editor_of_choice? – Dcoder14 Oct 02 '19 at 04:59
  • I just edited my answer. Hope it helps. Let me know if you have any further questions :) – Scott Oct 02 '19 at 05:05
  • ok. Thank you. I have noted it down. but problem is I am unable to use sudo and whille using this, I am getting the above syntax error. – Dcoder14 Oct 02 '19 at 05:11
  • Your question is already asked before. For detailed explanation please take a look at [this](https://askubuntu.com/questions/73864/how-to-modify-an-invalid-etc-sudoers-file) and [this](https://askubuntu.com/questions/209558/how-can-i-fix-broken-sudo-sudo-parse-error-in-etc-sudoers-near-line-23) links – Scott Oct 02 '19 at 05:14
  • sherzod, while using the above command u mentioned, m getting the same error as - /etc/sudoers: syntax error near line 26 <<< sudo: parse error in /etc/sudoers near line 26 sudo: no valid sudoers sources found, quitting sudo: unable to initialize policy plugin – Dcoder14 Oct 02 '19 at 05:15
  • now it opens with pkexec visudo , can u plz tell me how to save changes and exit it. i am trying but not getting success. – Dcoder14 Oct 02 '19 at 05:25
  • thx, useful compare to reboot in recovery mode red-tape procedures... – Rγσ ξηg Lιαη Ημ 雷欧 Jan 14 '22 at 18:34
2
we have to write -
pkexec visudo
And it will open the file and one need to change as previous if any made.
Then type Ctrl+X which will ask to save the file. So type: Y and Enter
Dcoder14
  • 1,831
  • 3
  • 12
  • 22
0

This should open visudo up in nano.

$ export EDITOR=nano && sudo -E visudo
  • After this what should I do ? as when trying to use sudo command I am getting above error. – Dcoder14 Oct 02 '19 at 05:02
  • Ahh sorry my mistake, I thought that it wasn't opening correctly. In the case of a corrupt sudoers file I believe that is best answered here: [link](https://askubuntu.com/questions/73864/how-to-modify-an-invalid-etc-sudoers-file) – Cameron Milton Oct 03 '19 at 01:59