Passwordless sudo

To allow a user to run sudo without entering a password, edit the sudoers file:

sudo visudo

Find the user rules section (usually after the line root ALL=(ALL:ALL) ALL) and add:

username ALL=(ALL:ALL) NOPASSWD: ALL

where username is your actual username.

Save and exit (Ctrl+XYEnter in nano).

Verify:

sudo whoami

Should return root without asking for a password.


Is this safe?

If you are the sole administrator of the machine and your account is properly secured (SSH key, strong password, FDE), this does not create an additional security hole. The sudo password prompt protects against accidental command execution, not against an external attacker — if someone already has access to your session, the sudo password won't stop them.

On servers with multiple administrators it is better to keep the password enabled for auditing and protection against lateral movement.