Enabling Sudo Access via Cli

Reading Time: 1 minute

You will need to be root to create this new user. Once the user has sudo access they will have the same rights as the root user

1. Create the user

adduser kmarquis

When you create the user you get this output.

Adding user `kmarquis' ...
Adding new group `kmarquis' (1001) ...
Adding new user `kmarquis' (1001) with group `kmarquis' ...
Creating home directory `/home/kmarquis' ...
Copying files from `/etc/skel' ...
Enter new UNIX password: #Set Password
Retype new UNIX password: #Confirm Password
passwd: password updated successfully
Changing the user information for user
Enter the new value, or press ENTER for the default
Full Name []:
Room Number []:
Work Phone []:
Home Phone []:
Other []:
Is the information correct? [Y/n] y

2. Grant them sudo access by either:

a) usermod -G sudo kmarquis

or

b)  visudo
look for the line

root (ALL=ALL:ALL) ALL

add below:

kmarquis (ALL=ALL:ALL) ALL

Hit Ctrl + X then Enter.

Now with whatever method used, the user will have root privileges via sudo. If you need to make any changes that require root access, you just need to enter sudo before the command. You will be prompted for your password before the command is run

[email protected]:~$ sudo apt-get update
[sudo] password for kmarquis:

The following two tabs change content below.

Keeran Marquis

Network Engineer
Keeran Marquis is a Network Engineer. His main goal is to learn everything within the Networking field, pick up a little bit of scripting, be a poor man sysadmin and share whatever he knows! All Posts are his own views, opinions and experiences, no guarantees they will work for you but point you in the right direction 🙂
Share this:
Share

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.