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:

In Joomla, managing users involves creating user accounts, assigning user roles and permissions, and controlling user access to different parts of the website. To manage users in Joomla, you can navigate to the User Manager section in the Joomla administration...
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 ...
To reply to a user on Bitbucket, you can navigate to the comment section of the specific file or pull request where the user has left a comment. Type your reply in the text box provided below the user's comment and then click the "Reply" button to ...
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 get a user id from a table using Hibernate, you can create a query using Hibernate's Criteria or HQL (Hibernate Query Language). You will need to specify the table you are querying and the criteria for selecting the user id. Once you have defined your q...
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...