How to add a user to sudoers

2 minutes read

Separation of privileges are a security measure implemented in Linux systems. Regular/normal users operate with limited privileges in order  to reduce their influence in the system environment that they use. This is a security method to reduce the impact of regular users on the system.

In Linux a root user exist which has super-user access/privileges. This is an administrative account that has no restrictions. Normal users can execute commands with root access in a few ways.

How to obtain Root Access Level

To obtain root access level, open a new terminal window, and login as root.

Example: su – or su root 

Method 1 (recommended)

The sudoers file (the file in which are defined the access levels) is located at /etc/sudoers. !!! Be aware, do not modify it unless you know what you are doing !!!

su –
ls
cd /
ls
vim /etc/sudoers 

The sudoers file will open and the contents can be read.

linux sudoers vim errorbits.com

The text editor is called vim, the file is opened in read mode by default. The commands to edit the file can be found below:

i: input mode

ESC: exits to read mode

:q: quits (is no modifications are made)

:q!: quits (if modifications are made but you do not wish to keep them)

:wq!: save (saves the modifications added and quits vim)

Add your username to the sudoers file, save and close it, exit root.

Method 2

This is a simpler way, but depending on the system config that your Linux operating system has, it might not take effect very quickly.

There are two command lines that you can run:

sudo gpasswd -a username wheel

or

sudo usermod -aG wheel username

Your username has now administrative/sudo/root access level.

Facebook Twitter LinkedIn Telegram Whatsapp Pocket

Related Posts:

As you already know, in Windows just after the install there are a few standard directories like: Windows, Program Files, Documents and Settings/Users. In Linux a similar structure exists but with much more directories. I will present you below the most import...
Git refspecs specifies the patterns for references on the remote side and the locally tracked branch. When you create a new repository and add a new remote to it i.e git remote add origin url
Linux Directory Map / Structure Root   Path  Description bin/ ( -> usr/bin) Files that can be executed (binary files) used to troubleshot or debug the operating system. boot/ Contains a minimum number of files needed by the operating system to boo...
Metacharacters We often want to refer to a group of files or directories that have a common characteristic. To do this, there are some small constructs which helps the user to filter the needed files. For example if in a folder we have a lot of jpg, mp3 and do...
Linux server logs are files containing recorded events and messages related to system activities and processes. These logs provide crucial information for system administrators to diagnose issues, monitor system performance, and troubleshoot problems. They hel...