Enable Sudo Without Password on Ubuntu / Debian
You can configure a Linux user to run sudo commands without entering a password.
This is useful for development servers, homelabs, CI/CD runners, automation scripts, and machines where passwordless sudo is intentionally required.
Recommended: Use a Separate sudoers.d File
Instead of modifying /etc/sudoers directly, create a dedicated configuration file under /etc/sudoers.d/.
For example, for user joos:
sudo tee /etc/sudoers.d/99-joos-nopasswd >/dev/null <<'EOF'
joos ALL=(ALL) NOPASSWD:ALL
EOF
Set the correct permissions:
sudo chmod 0440 /etc/sudoers.d/99-joos-nopasswd
Validate the sudo configuration:
sudo visudo -c
If everything is correct, the output should indicate that the sudoers configuration files parsed successfully.
Test passwordless sudo:
sudo -k
sudo whoami
Expected result:
root
You should not be prompted for a password.
Generic Version
Replace username with the actual Linux username:
sudo tee /etc/sudoers.d/99-username-nopasswd >/dev/null <<'EOF'
username ALL=(ALL) NOPASSWD:ALL
EOF
sudo chmod 0440 /etc/sudoers.d/99-username-nopasswd
sudo visudo -c
Traditional Method: Edit sudoers with visudo
The traditional method is to edit the main sudoers configuration using visudo:
sudo visudo
Then add:
username ALL=(ALL) NOPASSWD:ALL
For example:
joos ALL=(ALL) NOPASSWD:ALL
visudo validates the syntax before saving, which helps prevent an invalid sudo configuration.
However, using a separate file under /etc/sudoers.d/ is usually cleaner because custom configuration stays separate from the main /etc/sudoers file, is easier to identify or remove, and is easier to manage with automation or provisioning scripts.
Remove Passwordless Sudo
If you used the recommended method:
sudo rm /etc/sudoers.d/99-joos-nopasswd
sudo visudo -c
For another username, remove the corresponding file.
Security Note
The following rule gives the user unrestricted passwordless sudo access:
username ALL=(ALL) NOPASSWD:ALL
Use it only for trusted users and systems where passwordless sudo is intentionally required. For production environments, consider granting passwordless access only to specific commands instead of using unrestricted NOPASSWD:ALL.

