Pasword-less sudo for a user

Yes, I know it’s bad practice. Yes I know we shouldn’t let someone ‘privilege-up’ from a normal user to root-level privs without authenticating – but sometimes we need to, and don’t just want to give them the root password (for ‘su’, for example).

In Ubuntu (17.04, may work with other distros too), this can be accomplished by:

me@machine:~$ sudo visudo

Then within this file, at the *very* end add:

me ALL=(ALL) NOPASSWD: ALL

Where ‘me’ is your username. Save. Reboot. Pray that no one else knows your (me’s) password. Voila.

I’ve had to do this several times over the years, and have to Google it every time, so thought I would jot it down for prosperity / others.

Advertisements