How to add user to sudoers & add user to sudo group on ubuntu

How to Add User to Sudoers & Add User to Sudo Group on Ubuntu

Ubuntu is largely regarded as one of the easiest Linux distributions to operate, and it provides a simple technique for assigning the administrator privileges to other users on our machine. This sudo command is very important for this task.

We can add a user to both the “sudoers” file and the “sudo” group to offer the necessary access for administrative tasks. This mechanism enables them to properly execute the privileged commands. We can provide these rights by following a few simple steps.

Ubuntu users can verify that the other individuals have the necessary administrative privileges by configuring the “sudoers” file and adding a user to the “sudo” group. This improves teamwork and speeds up the completion of critical system tasks.

Creating
Sponsored
a New User

Log in as the root user or super user:

$ sudo -i

Now, add a new user with the help of this command.

The basic syntax is:

$ sudo adduser username
$ sudo adduser newuser

We can replace the username with any username that we want here. We take the “newuser”.

See also  Xubuntu Vs. Ubuntu

‘adduser’: It is a program to manage the user accounts in Ubuntu and other Debian-based Linux editions.

‘username’: This is a placeholder for the user’s actual username which we want to add to the sudo group. We should change it to our desired username.

‘sudo’: Sudo is an abbreviation for “superuser do” and is used to run the commands with administrative rights.

‘usermod’: This unique command is used to modify the properties of the user.

‘-aG’: These choices are used in conjunction to add a user to a group.

‘sudo’: This field specifies the group to which the user should be joined. It’s the “sudo” group in this situation.

‘newuser’: This is the user whose username we wish to change.

We can now check if the user is part of the “sudo” group. We need to enter the following to see the groups to which a user belongs:

# groups newuser

“groups”: This command retrieves and displays the groups to which a user belongs.

“newuser”: This is the user whose group membership information we want to retrieve.

# groups newuser

newuser : newuser sudo

Verify Sudo Access on Ubuntu

Change users by typing:

# su – newuser

In the first step, replace the “newuser” with the username that you specified. When prompted, we can enter our password. We can execute the commands normally by typing them.

$ ls /home

Some operations or places, however, necessitate the advanced access. It shows us the “access denied” error.

$ sudo ls /root

Our password is requested by the system so, enter the password that we created in the first step.

# sudo su – newuser

$ ls /home

newuser

$ sudo ls /root

[sudo] password for newuser: [Enter the password]

‘ls /home’: This displays a list of the contents of the “/home” directory which is usually used to store the user home directories.

‘sudo ls /root’: This runs the ls/root command as root. By typing this, you can see the files and programs of the root directory.

See also  Ubuntu Weekly Newsletter Issue 838

Add Users to the “Sudoers” File

Along with adding a user to the “sudo” group, we can also add them to the file called “sudoers”. We can create unique security policies and offer a personalised command access, thanks to this.

Change the username in the “sudoers” file.

To take the effect, the user should save and exit the file after adding the user to the “sudoers” file.

Conclusion

Finally, Ubuntu’s user management system, with the use of the “sudo” command, simplifies the process of granting administrative privileges to the users. By adding users to both the “sudoers” file and the “sudo” group, Ubuntu enhances the teamwork and expedites the critical system tasks. Through the outlined straightforward steps, the users can easily create new accounts and verify their sudo group membership. Users can also grant the necessary access for administrative functions. Additionally, the ability to customize the security policies in the “sudoers” file adds flexibility to the user access control. This process fosters efficient collaboration and contributes to the creation of a secure and productive Ubuntu environment.


Discover more from Ubuntu-Server.com

Subscribe to get the latest posts sent to your email.

Comments

No comments yet. Why don’t you start the discussion?

    Leave a Reply