• Wed. May 22nd, 2024

Scorebigwinners

Fuel Your Curiosity.

Easily Create a Sudo User on Ubuntu 24.04 From Terminal – Best Practices

ByAdministrator

May 21, 2024

This guide intends to teach you to Create a Sudo User on Ubuntu 24.04 From Terminal. In Ubuntu 24.04, a sudo user is a regular user who has access to administrative privileges for running commands with root privileges. This can be done by running commands with sudo, “superuser do.” You can use sudo for many tasks, such as installing software, modifying system configurations, and managing users, without logging in as the root user.

Here are some tasks you can do with a sudo user on Ubuntu 24.04:

Get Admin Points: A sudo user can temporarily get root privileges to run commands that need higher permissions.Security: Using sudo reduces the security risks instead of using root users.Accountability: Sudo logs all commands executed with high-score privileges. It provides an audit trail for administrative actions.

To see how to Create a Sudo User on Ubuntu 24.04, you can follow the steps below.

Simple Guide Steps To Create a Sudo User on Ubuntu 24.04

To Create a Sudo User on Ubuntu 24.04, you need to log in to your server, open a terminal CLI, and follow the steps below. You can SSH to your server as a root user. Here we log in as a non-root user with sudo privileges.

First, you must run the system updates with the command below:

sudo apt updateAdd a New Sudo User on Ubuntu 24.04

You can easily use the adduser command to Create a Sudo User on Ubuntu 24.04. The syntax command looks like this:

adduser username

For example, we create a user named noble with the following command:

sudo adduser noble

You must set a password for your user and other information. You can leave the other information blank by pressing enter. Your output should look like this:

Then, you can add your user to the sudoers for getting admin privileges. For this purpose, you can use the usermod command. This will help you to add your users to the sudoers group. The syntax command looks like this:

usermod -aG sudo username

For example, for adding the noble user to the sudoers, we can use the command below:

sudo usermod -aG sudo noble

Note: All users’ details are stored in a file named the /etc/passwd file. To verify that the user was created, you can view this file using the cat command or view more details with the id command:

# cat /etc/passwd | grep noble
# id noble

In your output, you will see:

Check User details on Ubuntu 24.04

Next, you can switch to your new user account from the terminal by using the following command:

su – noble

You must enter the user password and try to run the commands by using the sudo. For example, run the system update:

Test Sudo user on Ubuntu 24.04

Note: It is recommended to consider the following practices for sudo user:

Only use sudo when necessary to reduce potential security risks.After completing admin tasks, log out of the sudo session to reduce the risk of accidental system changes.Regularly check the sudo logs in /var/log/auth.log to monitor the usage of sudo privileges.

Also, if you plan to remove the users, you can proceed to the next step.

Delete Users on Ubuntu 24.04

At this point, if you would like to delete and remove your user, you can use the following syntax:

deluser username

For example, to delete the noble user, we can execute the following command:

sudo deluser noble

Also, you can delete the user with its home directory by using the following command:

sudo deluser noble –remove-home

That’s it, you are done.

Conclusion

A sudo user in Ubuntu 24.04 is a regular user who can execute commands with root privileges using the sudo command. This user setup allows users to do admin tasks without logging in as the root user. As you can see, you can easily Create a Sudo User on Ubuntu 24.04 From Terminal CLI. Also, you can easily remove and delete a user with its home directory with the deluser command.

Hope you enjoy it. If you are interested in Ubuntu 24.04, you can also check the following articles:

Basic UFW Firewall Configuration on Ubuntu 24.04

Set a Static IP Address on Ubuntu 24.04 Via GUI

Ubuntu 24.04 LTS Desktop Installation

Leave a Reply

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