Site icon VPS Windows

How to Add and Delete Users on Ubuntu 20.04 VPS and Assign Sudo Rights to users

Add and delete users 1

Add and Delete Users on Ubuntu 20.04 VPS

Ubuntu is one of the most popular Linux operating systems, suitable for both beginners and experts. Managing users is crucial for ensuring security and effective system administration. In this guide, we will explore how to add and delete users on Ubuntu 20.04 VPS and assign sudo rights to users.

Why should the root account add and delete users on Ubuntu 20.04 VPS and assign sudo rights to users?

When using Ubuntu 20.04, the root account (the highest-level administrator) has unrestricted access to the entire system. However, directly using the root account is discouraged for the following reasons:

Enhanced Security

Using the root account for daily tasks poses a significant security risk. Even a minor mistake, like executing the wrong command, can lead to severe issues such as data loss or system damage. By creating new users and granting them sudo rights, you limit the scope of administrative power to specific tasks.

Prevent Accidental Errors

The root account imposes no restrictions on commands, increasing the risk of unintentional system damage. By creating a new user with sudo rights, you can ensure that password confirmation is required before executing critical commands, reducing the chance of errors.

Efficient System Management

Delegating tasks to users with varying permission levels simplifies system management. For instance:

Easier Activity Tracking

When multiple users access the system, using the root account makes it challenging to track who made specific changes. Assigning sudo rights to individual users allows you to monitor and manage the activity history of each user.

Compliance with Security Best Practices

Production systems often follow the principle of “least privilege,” which means granting only the necessary rights to perform tasks. This minimizes the risk of external exploitation or human errors.

Thus, adding new users and assigning sudo rights ensures better security and control over your system while simplifying server maintenance.

Add and delete users on Ubuntu 20.04 VPS

1. Adding a New User on Ubuntu 20.04 VPS

Creating a new user on Ubuntu is straightforward using the command-line interface.

Step 1: Log in to Your Ubuntu 20.04 VPS

Ensure you have access to a VPS running Ubuntu 20.04. When you login in, you will operate as the root user.

Step 2: Create a New User

Run the following command to add a new user:

adduser <username>

For example, to create a user named vpswindows:

adduser vpswindows

The system will prompt you to:

Step 3: Verify the User

To check the newly added user, run:

cat /etc/passwd

This will display a list of all users, including the newly created one.

2. Deleting a User on Ubuntu 20.04

If a user account is no longer needed, you can delete it to keep the system clean and secure.

Step 1: Delete the User

Use the following command to delete a user:

deluser <username>

For example, to delete the user vpswindows:

deluser vpswindows

Step 2: Delete the User’s Home Directory

To also delete the user’s home directory, use the –remove-home option:

deluser --remove-home vpswindows

Step 3: Verify Deletion

To confirm that the user has been deleted, check the /etc/passwd file:

cat /etc/passwd

3. Assigning Sudo Rights to a User

Sudo rights allow a user to execute administrative commands like installing software or modifying critical settings.

Step 1: Add the User to the Sudo Group

Use the following command to grant sudo rights:

usermod -aG sudo <username>

For instance, to grant sudo rights to the user vpswindows.com:

usermod -aG sudo vpswindows

Step 2: Verify Sudo Rights

Log in as the user and run:

sudo whoami

If the command returns root, the user has been successfully granted sudo rights.

Important Notes

Conclusion

Add and delete users on Ubuntu 20.04 VPS and assign sudo rights to users not only helps you manage the system more easily but also improves security. If you have any questions or need assistance with Windows/Linux VPS services, feel free to contact us for consultation and free account registration!

Exit mobile version