Add User to Sudoers List in Debian

Add A User To SudoersSome times on a multi-user system it may be beneficial to allow particular users to do things that require root privileges without having to give them the root password. There is a tools which will solve this problem, a well known tool for this purpose is called sudo.

sudo is a portable application for giving users selectively increased permissions.

Add A User To Sudoers List

The Debian sudo package is available for all the releases and will setup a minimal configuration file when it is installed. This may already be installed on your system.

sudo is configured entirely through the file /etc/sudoers. This file controls the commands which users are allowed to run.

The program is flexiable enough to allow users to be given the ability to run commands as any local user it is typically used to give root privileges for commands.

You need to have root access to do this.
1. To become root use the following command and press Enter.

user@DistroGeeks:~$ su

2. Enter root password and press Enter.

user@DistroGeeks:~$ su
password:

3. Now you can add the user to sudoers list with the following command, Then press Enter.

user@DistroGeeks:~$ su
password: 
root@DistroGeeks:/home/user# visudo

4. Scroll down to ‘# User privilage specification’.

# /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

5. To give full root privileges to a single user system simple mimic the root specification like so. However on a system with multible users, this user will now have full root privileges which means he may access other users files no matter what access rights you set. All privacy is lost.

# /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
user     ALL=(ALL) ALL

6. Sudo was ment to be used so that you give a user access to some of the commands which need root access. Sudo was not ment to be used as a full root replacement. It is safer to give access to a specific command such as apt-get like so.

# /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
user     ALL=/usr/bin/apt-get

7. Save the file with (CTRL+O) and close it with (CTRL+X)

8. Now user will be able to update and install using apt-get.

user@DistroGeeks:~$ sudo apt-get update
[sudo] password for user:

More info on the many setting for sudoers can be found at en.wikipedia.org.

 

Please, feel free to rate this post or comment below.

 

External Links

• Home: http://www.debian.org/
• Wiki: http://wiki.debian.org/