Home‎ > ‎Basics‎ > ‎

Sudo without password in Ubuntu

In commandline type:

$ sudo visudo

It opens a file /etc/sudoers in nano text editor, as /etc/sudoers.tmp

Add the last line:

yourusername ALL=(ALL) NOPASSWD: ALL

#
# This file MUST be edited with the 'visudo' command as root.
#
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
#
# See the man page for details on how to write a sudoers file.
#
Defaults        env_reset
Defaults        secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:$

# Host alias specification

# User alias specification

# Cmnd alias specification

# User privilege specification
root    ALL=(ALL:ALL) ALL

# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL

# Allow members of group sudo to execute any command
%sudo   ALL=(ALL:ALL) ALL

# See sudoers(5) for more information on "#include" directives:

#includedir /etc/sudoers.d

mike ALL=(ALL) NOPASSWD: ALL

My username is mike, so I added mike ALL=(ALL) NOPASSWD: ALL as you can see above.

Press Ctrl + X to exit nano and confirm writhing changes to the file with "y".

Now it's done, it should work without restarting or reloading anything.