It's already Friday, and I'm delighted 😉 to see you here.
Another day of problem-solving, so we'll see how it goes.
sudo command allows regular users to gain administrator rights that are usually only available to the root user. This post will show you how to create a new
sudo user on Ubuntu 18.04 or 20.04.2.0 without having to change the /etc/sudoers file on your server.
follow the steps below to achieve the expected result
1. Login / ssh into your server
Use this command if you are already logged in to the server to switch to the root user.
2. Create New User
adduser command to add a new user to your system:
You may add
sudo if you are not logged in with the root user account.
You will be prompted to enter a new password and retype the new password.
Adding user `soft' ... Adding new group `soft' (1002) ... Adding new user `soft' (1002) with group `soft' ... Creating home directory `/home/soft' ... Copying files from `/etc/skel' ... New password:
After that, you'll be prompted to enter some details about the new user. Accepting the defaults and leaving all of this information blank is fine, but you can also set them.
Enter the new value, or press ENTER for the default Full Name : Idris Room Number : 1234 Work Phone : 01-279019 Home Phone : 44-795004 Other : Is the information correct? [Y/n]
3. Add user to
To add the user to the
sudo group, execute the
usermod command, replacing
soft with the username you just added. All members of the
sudo group have full
sudo rights by default on Ubuntu.
usermod -aG sudo soft
4. Switch to the new account and Test
Check that you can use
sudo as a new user by appending
sudo to the command you want to run with superuser privileges.
Now run any command to test, for example.
sudo ls -a
When you use
sudofor the first time in a session, you'll be requested for that user's password. To continue, enter the password:
Yay 🥳 we were able to create a new user on our machine.
See you next Friday in DevOpsFriday series. Take care!!!