Sudo allows us to provide superuser privileges to a normal user with restrictions. It allows users to run programs with the privileges of other users. One can configure sudo to give root privileges to specific commands only.
This tutorial helped you to create a new user with Sudo privileges, add an existing user to sudo privileges or remove sudo privileges from any account.
Create User with Sudo Access
Use the system’s default “adduser” command to create a new account. As per current requirements the command syntax will be like:
sudo adduser [USER_NAME} [GROUP_NAME]
- USER_NAME is the name of the new user account.
- GROUP_NAME Define a group name here to automatically add user to this group during creation.
Let’s try with a real example. The following command will create a new user tecadmin and add it to sudo group.
sudo adduser tecadmin sudo
In case of user already exist, it will simply add the user to the sudo group.
Add Existing User to Sudo
You can also use the following command to add existing users to group sudo, where it will get full sudo privileges.
sudo usermod -aG sudo tecadmin
This will just add
tecadmin user to the sudo group. One can verify the same in the
Remove Sudo Privileges from User
The following command will remove a user from the sudo group. This will just remove the
tecadmin user from the s
udo group. It will not remove the user from the system.
sudo gpasswd -d tecadmin sudo
We also recommend viewing the /etc/sources file and removing any user-specific entry.
In this tutorial, You have learned to create a Sudo account in the Ubuntu system. Additionally provides you with steps to allow sudo access to the existing accounts. Also, remove sudo privileges from the user.