Debian: how to sudo without password

sudo_with_no_password

How to execute commands as root without being asked for the password is a convenient time saving option. But not just time saver, but also it will let you acting always as a the same user, so it will be easier to keep the history together.

Let’s say you want this exception to be applied just to your user and not to all users. For do this you have to edit your sudoers file using visudo:

 

# visudo

This is the normal content of the sudoers file:

 GNU nano 2.2.4                      File: /etc/sudoers.tmp                                                  

# /etc/sudoers
#
# This file MUST be edited with the 'visudo' command as root.
#
# See the man page for details on how to write a sudoers file.
#

Defaults        env_reset

# Host alias specification

# User alias specification

# Cmnd alias specification

# User privilege specification
root    ALL=(ALL) ALL

# Allow members of group sudo to execute any command
# (Note that later entries override this, so you might need to move
# it further down)
%sudo ALL=(ALL) ALL
#
#includedir /etc/sudoers.d

All you need to do is to add a line at the bottom of this file in the following format:
username ALL=NOPASSWD:ALL replacing “username” with the real name of an actual user. So for instance in my case my sudoers file will be:

 GNU nano 2.2.4                      File: /etc/sudoers.tmp                                                  

# /etc/sudoers
#
# This file MUST be edited with the 'visudo' command as root.
#
# See the man page for details on how to write a sudoers file.
#

Defaults        env_reset

# Host alias specification

# User alias specification

# Cmnd alias specification

# User privilege specification
root    ALL=(ALL) ALL

# Allow members of group sudo to execute any command
# (Note that later entries override this, so you might need to move
# it further down)
%sudo ALL=(ALL) ALL
#
#includedir /etc/sudoers.d
giuseppe ALL=NOPASSWD:ALL

Don’t forget to save (the editor of visudo is nano) with “ctrl+o” and close with “ctrl+x”.

Then try to login back as normal user and type:

# sudo su -

If all goes fine you should become root without typing any password.

Giuseppe 

(Visited 4,909 times, 1 visits today)

Author: Giuseppe Urso

Giuseppe lives in Haarlem now with his shiny dog, Filippa In 1982 received his first home computer, a Commodore 64, followed by Datasette and a 1541 Floppy Disk Drive. In 1999 he installed his first Linux distro (LRH6). In 2006 he switched to Debian as favourite OS. Giuseppe Urso actively sustains the Free Software Fundation and his founder Richard Mattew Stallman, he speaks to people trying to convince them to join the fight now, and about how important is to use Free Software only. He has a job as Infra Specialist at Hippo Enterprise Java Cms an Open Source Enterprise class Content Management System, one of the coolest company ever, in Amsterdam. He's always ready to install Debian on other people computers for free.

Leave a Reply

Your email address will not be published. Required fields are marked *

 

This site uses Akismet to reduce spam. Learn how your comment data is processed.