Adding your user to the sudoers file on Debian.

Posted: August 17, 2011. At: 2:30 PM. This was 6 years ago. Post ID: 1830

If you want to be able to use the sudo command in Debian to do superuser tasks as your normal user, then you need to edit the /etc/sudoers file to look like this. Use the visudo command to do the editing of the /etc/sudoers file, this will make sure the file is properly edited without errors before it is saved. in this example on Debian 6.0 I am using the username lovecraft and I have added myself to the /etc/sudoers file to be able to use sudo but still requiring to system to ask me for a password.

ubuntu ~ $ sudo cat /etc/sudoers
# 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        mail_badpass
Defaults        secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/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
lovecraft ALL=(ALL:ALL) ALL
# See sudoers(5) for more information on "#include" directives:
#includedir /etc/sudoers.d

The members of the group sudo can execute commands as root, and I could have added my user to this group, but I preferred to do it this way. using sudo requires you to have a very strong password on your normal user account as well as your root account unless you disable it with this command: sudo passwd -l root. This is how Ubuntu is set up, the root account is disabled and the sudo command is used to do superuser tasks. But you can set a password for the root account on Ubuntu by typing sudo passwd root.

No comments have been made. Use this form to start the conversation :)

Leave a Reply