I had the unfortunate experience to lock myself out from using sudo
on my NAS server.
All I wanted to do was give my user permission to run smartctl
, which usually requires root privileges. This can be achieved by editing the /etc/sudoers
file.
However I did not use visudo
for this task. After removing the pound sign from the #include
statement – which, let’s be honest, looks like a comment that needs to be uncommented – I saved the file and closed it.
At this moment visudo
would have raised an error, if I had used it, and prevented me from saving the invalid sudoers
file.
Long story short I was locked out from using the sudo
command. After booting into a Linux live/rescue image from USB I could fix the syntax error in /etc/sudoers
.
The moral of the whole story, better use visudo
when editing /etc/sudoers
.
That’s it.
References: