Add Sudo User and Permissions in Linux

How To Add Sudo User and Permissions in Linux

Sudo user in Linux will have permissions similar to a root user. With full sudo privileges, a user will be able to perform any operations on the Linux system.

It is very important to categorize a user as a sudo user based on the use case.

In this guide, we will look in to the following.

  1. Create a new Linux user
  2. Adding full sudo privileges to a user
  3. Adding sudo privileges for specific command execution.

Create a new Linux user

Step 1: Login to your server as root.

Step 2: Create a user using useradd command. Replace username with your custom user.

Step 3: Set a password for the user.

You will be prompted for updating the new password. Enter the required password.

Add sudo Privileges to a User

Now lets make our new user or an exiting user a sudo user.

Step1: Add the user to wheel group.

Note: If a user is part of wheel group, he can run any command as a super user.

Step 2: Execute visudo command to open /etc/sudoers file.

Step 3: Make sure the following line is uncommented in the file.

By default, even if a user is part of wheel group, you need to provide the password every time you run a command as sudo. If you need password less sudo access, you need uncomment the following where it has NOPASSWD and save the file using ESC + w + q + !

Step 4: Now lets test the sudo user by logging in as the user.

Now, try running sudo commands. It should work based on your password preferences (with or without password) you set for wheel group.

Adding sudo privileges for specific command execution.

There are scenarios where you might want only specific commands to be run a sudo privileges for a specific user. Lets see how we can achieve it.

You can group the set of commands to be run under Cmnd_Alias

For example, if you open the /etc/sudoers file, you can find the following aliases.

Lets say, you want a user to have only permissions to run commands under the SERVICES alias, you need to have the following entry in the /etc/sudoers file

Note: You can have custom commands in aliases the you create under Cmnd_Alias


Ruby on rails is an excellent framework for developing web apps using ruby. And to be clear, ruby on rails is not a…

Read more

This tutorial will teach you how to connect MySQL database and JSP on eclipse. I really had a hard time connecting JSP…

Read more

What is powershell:              Windows powershell is an excellent command line…

Read more

The Best Tutorials & Tips to Speedup Your DevOps Workflow.

Created by Bibin Wilson.