Bobcares

Adduser Digitalocean Droplet: A Note on

by | May 15, 2023

Let us take learn how to adduser Digitalocean droplet with the support of our DigitalOcean support services at Bobcares.

Adduser command in DigitalOcean droplet

adduser digitalocean droplet

One of the most important system administration jobs to learn is how to add and remove users on a Linux system.

When starting a new system, the root account is the only one accessible by default.

While operating as the root user provides us unlimited authority over a system and its users, it is also risky and potentially disastrous.

It’s advisable to add an unprivileged user and do typical system administration activities without root rights. We may also establish new unprivileged accounts for any other users on the system. Every user on a system should have their own account.

How to adduser in a Digitalocean droplet?

If we sign in as the root user, we can create a new user at any time by typing the following command:

adduser newuser

If we are the root user with sudo rights, we can add a new user using the command:

sudo adduser newuser

In any case, we will be required to reply to a series of questions to adduser digitalocean droplet:

  • Assign and confirm the new user’s password.
  • Fill in the blanks with any other information about the new user.
  • If we do not want to use these fields, we may skip this step by clicking ENTER.
  • Finally, we’ll be asked to validate the accuracy of the information we gave. Continue by pressing Y.

The new user is now available for usage and may be accessed using the password you specified.

Continue to the following section if the new user requires administrative rights.

Granting a User Sudo Privileges

If the new user is to be able to run commands with root (administrative) rights, we must provide the new user access to sudo. Let’s look at two ways to this task:

  • first, adding the user to a pre-defined sudo user group, and
  • second, setting rights in sudo’s setup on a per-user basis.

Adding the New User to the Sudo Group

On Ubuntu 20.04 computers, sudo is set to grant full rights to any user in the sudo group by default. This is the next step to adduser digitalocean droplet

Using the groups command, we can see which groups the new user is a member of:

groups newuser

output

newuser : newuser

As adduser produces this in addition to the user profile, a new user is only in their own group by default. The names of a user and its own group are the same. We may use the usermod command to add the user to a new group:

usermod -aG sudo newuser

The -aG option instructs usermod to add the user to the groups specified.

Please keep in mind that the usermod command requires sudo access. This implies that the root user or another sudo group member must login to add people to the sudo group.

In the latter instance, we must prefix this command with sudo, as seen below:

sudo usermod -aG sudo newuser

Specifying Explicit User Privileges in /etc/sudoers

Instead of adding the user to the sudo group, we may use the visudo command, which opens a configuration file named /etc/sudoers in the system’s default editor and allows us to directly define rights for each user.

Visudo is the best technique to modify /etc/sudoers as it locks the file against concurrent modifications and performs a validity check before overwriting.

This helps to avoid a situation in which we misconfigure sudo and are unable to resolve the issue because we have lost sudo access.

If currently we are in as root, run the following command:

visudo

If we are a non-root user with sudo rights, we can use the sudo prefix:

sudo visudo

Visudo has traditionally opened /etc/sudoers in the vi editor, which might be perplexing for new users.

Visudo will use the nano text editor by default on new Ubuntu installs, which provides a more comfortable and accessible text editing experience.

Move the cursor with the arrow keys and look for the line that looks like this:

/etc/sudoers
root    ALL=(ALL:ALL) ALL

Include the highlighted line below this one. Make careful to replace newuser with the name of the user profile to which we want to grant sudo privileges:

/etc/sudoers
root    ALL=(ALL:ALL) ALL
newuser ALL=(ALL:ALL) ALL

Add a new line like this for each person who should have full sudo access. When done, save and close the file using CTRL + X, then Y, and finally ENTER to confirm.

[Need assistance with similar queries? We are here to help]

Conclusion

To sum up we have now seen how to adduser Digitalocean droplet with the support of our tech team.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

0 Comments

Submit a Comment

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

Never again lose customers to poor
server speed! Let us help you.