How to add an ordinary user to the SUDOers list?


In the UNIX system, an ordinary user doesn’t have privileges to do everything he wants. A root user is the ultimate user. Some actions need Super User privilege. Super users can do such tasks using the sudo command. However ordinary users who are not in the sudoers list cannot do such tasks even with the sudo command. Only a root user can install, upgrade or remove programs or softwares. This article is about how you can add an ordinary user to the sudoers list.

You need to use the visudo command to edit the sudoers list. Off course you’ll need root access to use the visudo command.creaters of Linux aren’t dumb to let you become a root user without checking if you are really supposed to get it> The command to open the sudoers list is given below.

sudo visudo

The sudoer’s list is actually a file named sudoers.tmp in etc. The file looks like this if you open it with visudo command. What you see if is sudoers.tmp opened in an editor named nano.


GNU nano 2.2.2                   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 after they have
 # provided their password
# (Note that later entries override this, so you might need to move
# it further down)
%sudo ALL=(ALL) ALL
#
#includedir /etc/sudoers.d

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

^G Get Help      ^O WriteOut      ^R Read File     ^Y Prev Page     ^K Cut Text      ^C Cur Pos
^X Exit          ^J Justify       ^W Where Is      ^V Next Page     ^U UnCut Text    ^T To Spell

Notice line #19. Add a line like the one below just under line #19.


user    ALL=(ALL) ALL

Where user is the name of the user to whom you want to give root access.

Enjoy SUDOing 🙂