Whenever you use sudoand typing the wrong password, you can have the sudo application insult you:
fab-user@fab-manjaro:~
$ sudo ls /
[sudo] password for fab-user:
Hold it up to the light --- not a brain in sight!
[sudo] password for fab-user:
It can only be attributed to human error.
[sudo] password for fab-user:
sudo: 3 incorrect password attempts
To activate this feature:
sudo visudo
At the end of the file before the #includedir /etc/sudoers.d type:
Add the following to /etc/bash.bashrc or any of the other locations where you can configure your shell automatically during login:
if [ -f /etc/bash.command-not-found ]; then
. /etc/bash.command-not-found
fi
exit the terminal
open the terminal again
try it out
fab-user@fab-manjaro:~
$ cdd /home
Your application for reduced salary has been sent!
/bin/bash: cdd: command not found
fab-user@fab-manjaro:~
$ oops
What if I told you... it is possible to type valid commands.
/bin/bash: oops: command not found
fab-user@fab-manjaro:~
$ lf
Fake it till you make it!
/bin/bash: lf: command not found
P.S. 3★ difficulty because we’re changing the sudoers file here and if done incorrectly, no moresudofor you!!!
sudoedit or sudo -e is standard for whenever you are making a system file edit. except for editing sudoers
The funny thing is … its partially because visudo works a bit like sudoedit that you should.
But it does a little more - it wont allow you to create a malformed sudoers file.
How would one fix this? What happens when you do that (not having the Defaults insults at the proper place)? I guess to fix it you would use command su then modify the sudoers file with visudo?
Actually the best place to put that “directive” is in a separate config piece under /etc/sudoers.d, eg. like /etc/sudoers.d/00_insults
When you use visudo it won’t allow you to make mistakes that render sudo to error-out due to syntax errors.
But mistakes in functionality can always happen and the last resort would be to boot with single kernel option to drop to a root shell on boot and fix stuff from there on…
My advice would be to never modify the /etc/sudoers file, but instead always work with separate config pieces under /etc/sudoers.d …
I messed up I was unable to have sudo privilege again (I could su - and visudo, then I removed the Defaults insult line, rebooted but no sudo for me despite the sudoers file back to its previous state, so I Timeshifted from a month old backup), but that is maybe because I have previously modified the sudoers file and have a line at the bottom to be able to execute some commands with sudo without password maybe, I don’t know, this is what I have at the very bottom of my sudoers file:
So two question, is it right to have placed this line at the very bottom? Should I move it somewhere else?
I’m not sure what would be the best thing to do. I’ll do another Timeshift backup now I have restored the system from previous backup and upgraded everything again, I think I might do the other approach and use the external file to add this as TriMoon suggested.
//EDIT: TriMoon suggestion worked like a charm, I don’t know why I messed up before, I think my line at the very bottom of sudoers file might be the culprit.