Skip to content

Passwordless sudo on Ubuntu

To enable passwordless sudo for a specific user on Ubuntu, you need to make some changes to the sudoers configuration. Here's a step-by-step guide:

  1. Open a terminal on your Ubuntu system.
  2. Type the following command to edit the sudoers file using the visudo command, which ensures you don't accidentally introduce syntax errors:
    sudo visudo
    
  3. The visudo command will open the sudoers file in a text editor (usually nano). Look for the line that says %sudo ALL=(ALL:ALL) ALL. This line grants sudo access to the "sudo" group.
  4. Below the %sudo line, add a new line for the specific user you want to enable passwordless sudo for. The line should follow this format:
    username   ALL=(ALL) NOPASSWD:ALL
    
  5. Replace username with the actual username of the user you want to configure. For example, if the user you want to enable passwordless sudo for is called "john," the line would look like this:
    john   ALL=(ALL) NOPASSWD:ALL
    
  6. Save the changes and exit the text editor. In nano, you can do this by pressing Ctrl + X, then Y to confirm, and finally Enter to save the file with the same name.
  7. Once you're back at the terminal, the passwordless sudo configuration should be in effect for the specified user. They will be able to run sudo commands without entering a password.

Please note that modifying the sudoers file requires administrative privileges, so you may need to enter your own password to perform these steps. Additionally, exercise caution when granting passwordless sudo access, as it can pose security risks. Make sure you only enable it for trusted users who need it for specific purposes.