How to make a user a sudoer
Sudo is the basic mechanism on Ubuntu to perform tasks that normally are reserved for the user root only. A sudoer is a user that can use the sudo mechanism.
By default, all users of the group admin are sudoers. That means adding a user to the admin group makes him/her also a sudoer. To do that, in your root account type this in the console:
adduser <name_of_the_user> admin
If you don’t want to add this user to the admin group; but make him/her a sudoer, you have to add the user to the sudoers file via the editor visudo. This editor is used to open a temporary file with the name /etc/sudoers. In this file, you can define all sudo tasks that are available on your server. You should never open the /etc/sudoers file for editing directly; because that involves the risk of completely locking yourself out if you make an error.
Default configuration in /etc/sudoers is as follows:
# /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
# Uncomment to allow members of group sudo to not need a password
# (Note that later entries override this, so you might need to move
# it further down)
# %sudo ALL=NOPASSWD: ALL
# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL
You could add a user (named onur) to the end of this file like this:
onur ALL=(ALL) ALL
That would allow the user onur to be a sudoer (and here, who can perform all sudo commands) after you saved the file. You could also restrict commands to him by specifying each command he could use, like this:
onur ALL=/sbin/shutdown
This would only allow onur to use the /sbin/shutdown command instead of all sudo commands.
If the admin group is not present in your installation, you can create one by typing:
addgroup --system admin
This created a system group named admin and then you can manually add this line to the /etc/sudoers file via visudo:
%admin ALL=(ALL) ALL