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:

To add users to a Ubuntu server, follow these steps:Connect to the server: SSH into the Ubuntu server using the terminal or an SSH client. Switch to root user: Execute the command su - and enter the root user's password. Create a new user: Use the adduser ...
You can read user input in Bash using the read command. The syntax is as follows: read [OPTIONS] [VARIABLE] Here, OPTIONS are the different options or flags that can be used with the read command, and VARIABLE is the name of the variable that will store the us...
To commit changes to a Git repository, you need to follow these steps:Add files to the staging area: Use the command git add to add specific files or git add . to add all modified files to the staging area. This prepares them for the commit. Check the status:...
To create a user in Ubuntu Linux, you can follow these steps:Open the terminal by pressing Ctrl+Alt+T or searching for "Terminal" in the applications menu. Type the command sudo adduser username in the terminal. Replace "username" with the desi...
To configure Git user settings, you can follow these steps:Open the Git Bash or Terminal.Set up your global username by typing the following command and replacing "Your Name" with your desired name: git config --global user.name "Your Name" Set...
Creating user interfaces in Kotlin involves using the Android framework and the XML layout files to define the structure and design of the UI components. Here's an overview of how you can create user interfaces in Kotlin:Layout Files: Start by creating XML...