How to Run Sudo Commands Without Password

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 Step-by-Step Guide to Disable Sudo Password Requests Follow these steps; S

Last updated 30 Nov 2026Also in: Dedicated Servers

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

  1. Root or sudo access: You need access to the server as a root or sudo user to modify user permissions.
  2. 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 the sudoers file, which can potentially lock you out of sudo 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 hit Enter to save and exit
    • If you are using Nano press CTRL + X, then Y, and hit Enter to save and exit if you are using Nano
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.

cloud servers in kenyaservers