Configure sudo without password on Ubuntu 20.04 Focal Fossa Linux

In this tutorial you will learn how to configure sudo without the password. Meaning that the sudo command will not prompt you to enter password hence rendering your sudo command completely passwordless.

WARNING
Configuring your sudo command with no password may lead to a security breach, hence leaving your system and data compromised. You are adviced not to proceed with sudo passwordless configuration!

In this tutorial you will learn:

  • How to disable password for the sudo command
  • How to disable sudo password for a specific administrative commands

Configure sudo without password on Ubuntu 20.04 Focal Fossa Linux

Configure sudo without password on Ubuntu 20.04 Focal Fossa Linux

Software Requirements and Conventions Used

Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System Installed Ubuntu 20.04 or upgraded Ubuntu 20.04 Focal Fossa
Software N/A
Other Privileged access to your Linux system as root or via the sudo command.
Conventions # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ – requires given linux commands to be executed as a regular non-privileged user

Configure sudo without password on Ubuntu 20.04 step by step instructions

  1. First you might want to consider to disable sudo password only for a selected administrative command(s). To do so you need to edit the /etc/sudoers sudo configuration command using the sudo visudo editor.

    For example to allow a single user eg. linuxconfig to execute the systemctl and reboot commands without sudo password add the following line into the /etc/sudoers configuration file:

    linuxconfig ALL=(ALL) NOPASSWD:/usr/bin/systemctl /usr/sbin/reboot 
    

    At this point executing the systemctl and reboot commands will not require sudo password.



  2. Next, if you wish the linuxconfig user to execute all commands using sudo with no password change the configuration line from Step 1 to:
    linuxconfig ALL=(ALL) NOPASSWD:ALL
    
  3. Lastly, in case you need all members of the sudo group to execute any commands using passwordless sudo, change the configuration line from Step 1 to:
    %sudo   ALL=(ALL:ALL) NOPASSWD:ALL