For example, if I type, sudo synaptic and enter a wrong password, I get 3 tries to get it right. I want sudo to only give me 1 try and exit with error code 1 if the password is incorrect.

  • 1
    Answer below, but I think this is a bad idea — it's going to result in passwords typed on the command line in cleartext by accident, because you're not going to change the default everywhere in the world. – mattdm Jan 14 '17 at 1:17

Go to user terminal (not root) and run sudo visudo. Default terminal editor should open.
Add these lines:

## Allow a user to attempt to enter a password 1 times
Defaults        passwd_tries=1

You should be ok.

Also see man sudoers

PS: About exit code, in my sudo when i run sudo ls;echo $? , after 3 wrong attempts i get exit code 1.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.