By default, when you run a command with sudo
, you’ll be prompted for your password. However, you can configure your server to allow specific users (or all users) to run sudo
commands without entering a password.
Prerequisites #
- Root or sudo access: You need access to the server as a root or sudo user to modify user permissions.
- Sudo user account: Ensure the user account for which you want to disable the password request is already set up for
sudo
privileges.
Step-by-Step Guide to Disable Sudo Password Requests #
Follow these steps;
Step 1: Edit the Sudoers File – The adjustments are done on the sudoers file #
- Access your server’s SSH with root or a sudo-enabled user. See these steps
- Open the sudoers file for editing using the
visudo
command.visudo
is used because it prevents syntax errors in thesudoers
file, which can potentially lock you out ofsudo
access
sudo visudo
- dd the following line to the bottom of the file to allow a specific user to run
sudo
commands without a password: - Replace
username
with the actual username of the user.
username ALL=(ALL) NOPASSWD:ALL

- This line grants that user full sudo privileges without requiring a password.
- You can also do that by adding the user to a group like sudo or wheel, then allow all users in that group to run sudo commands without password. In that case, you will allow all members of a group to run sudo commands without a password by adding one lines, depending on your group
- Add a user to group wheel or sudo using the commands below
usermod -aG wheel userName OR usermod -aG sudo userName

- Then depending on where you added the user, one of the lines below to sudoers file (visudo)
%sudo ALL=(ALL) NOPASSWD:ALL
%wheel ALL=(ALL) NOPASSWD:ALL

Step 2: Save and Exit #
- After editing the sudoers file, save the changes.
- If you are using vim, press :
wq
, then hitEnter
to save and exit - If you are using Nano press
CTRL + X
, thenY
, and hitEnter
to save and exit if you are using Nano
- If you are using vim, press :
Step 3: Test the Changes #
- To verify that the changes have been applied:
- Log in as the user for whom you disabled the password prompt
- Run any
sudo
command. For example:
sudo apt update OR sudo yum update
- If the configuration was done correctly, you should not be prompted for a password.
