I just got a Pi-4. I'm not sure if I did something wrong while setting it up, but after getting it running I noticed that sudo
commands required no passwords. I tried to change this, following some advice I found here:
How to change user pi sudo permissions; how to add other accounts with different permissions?
As that person recommended, I first added an admin user:
$ sudo adduser admin
Then I did the following:
$ sudo adduser admin sudo
$ sudo adduser admin adm
I then checked the user's privileges as advised, and it worked great. All good so far. Then I did the following as recommended:
$ sudo deluser pi sudo
$ sudo deluser pi adm
That worked great, too. Then I did something foolish. Unclear on precisely what I was supposed to do next, I opened up 010_pi-nopasswd
to edit it. The file contained just one line:
pi ALL=(ALL) NOPASSWD: ALL
I changed it -- and here is the foolish part, working faster than I was thinking -- to this:
pi ALL=(ALL) NOPASSWD:
The Pi did NOT like this. Whether I am logged on as admin or pi I cannot use sudo
for anything.(I did not create a root password before doing all this, so I can't use su
either.) This means I also cannot go back and edit that file. Any attempt to do so triggers the following:
>>> /etc/sudoers.d/010_pi-nopasswd: syntax error near line 1 <<<
sudo: parse error in /etc/sudoers.d/010_pi-nopasswd near line 1
sudo: no valid sudoer sources found, quitting
sudo: unable to initialize policy plugin
Likewise, any other use of sudo
triggers the same. Is there any way around this problem or have I effectively ruined the OS?
pkexec
might be installed and working, try using that instead ofsudo
.