How to Create a Sudo User on Ubuntu
Sudo is a program that runs on Unix-like computer operating systems that enables users to execute programs under the privileges provided by another user, usually the superuser. Sudo refers to either “substitute user do” or “super user do” either of which allows you to temporarily elevate your user account to have root privileges. This is not the same as “su”, which has a more permanent effect.
Our goal here is to walk you through setting up a sudo user on Debian,
Step 1: Configure VPSie cloud server
- Sign in to your system or register a newly created one by logging in to your VPSie account.
- Connect by SSH using the credentials we emailed you.
- Once you have logged into your Ubuntu instances and update your system.
Run the command to upgrade your system,
# apt-get update && apt-get upgrade -y
Step 2: Install sudo
Installing Debian Without sudo is possible. In that case, add sudo via apt-get,
# apt install sudo
Step 3: Register for a user account
Use the adduser command to create a new user account. The user information can be filled in or left blank by pressing ENTER. A user named “testuser” will be created here.
# adduser testuser
Adding user `testuser' ... Adding new group `testuser' (1000) ... Adding new user `testuser' (1000) with group `testuser' ... Creating home directory `/home/testuser' ... Copying files from `/etc/skel' ... New password: Retype new password: passwd: password updated successfully Changing the user information for testuser 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
Step 4: Add the new user to the sudo group
Run the following command to add the user you created to the sudo group,
# usermod -aG sudo testuser
Step 5: Test the sudo
To access the newly created user, type the following command,
# su - testuser
# su - testuser To run a command as administrator (user "root"), use "sudo <command>". See "man sudo_root" for details. testuser@LAX-d860-Ubuntu:~$
That’s all for now, I hope you’ve found this informative.
A sudo user on Ubuntu is a user account that has been granted permission to perform administrative tasks on the system using the sudo command. This allows the user to run commands as the root user, which has elevated privileges on the system.
To create a sudo user on Ubuntu, you can add the user to the sudo group. This can be done using the following command:
sudo usermod -aG sudo username
Replace “username” with the name of the user you want to add to the sudo group.
To remove a user’s sudo privileges on Ubuntu, you can remove the user from the sudo group. This can be done using the following command:
sudo deluser username sudo
Replace “username” with the name of the user you want to remove from the sudo group.
To check if a user has sudo privileges on Ubuntu, you can run the following command:
sudo -l -U username
Replace “username” with the name of the user you want to check. This will show the user’s sudo privileges, if any.
To run a command as a sudo user on Ubuntu, you can use the sudo command followed by the command you want to run. For example, to update the system packages as a sudo user, you can run the following command:
sudo apt update && sudo apt upgrade
This will update the system packages using the elevated privileges of the sudo user.
To switch to the root user on Ubuntu, you can use the following command:
This will switch to the root user’s shell and allow you to run commands as the root user. To exit the root shell, you can type the “exit” command.
To disable the sudo password prompt on Ubuntu, you can edit the sudoers file using the visudo command. This can be done using the following steps:
- Open the sudoers file in edit mode by running the following command:
- Find the line that starts with “%sudo” and add the following line below it:
username ALL=(ALL) NOPASSWD:ALL
Replace “username” with the name of the user you want to grant passwordless sudo access to.
3. Save and close the file.
Note that this should only be done if you are certain that the user has secure access to the system and you understand the security implications of passwordless sudo access.