How to Create a Sudo User on Ubuntu 24.04

When setting up a new Ubuntu 24.04 server or desktop, it is a security best practice to avoid using the root account for daily administrative tasks. Instead, you should create a standard user account and grant it ‘sudo’ privileges. This allows the user to execute administrative commands only when necessary.

Step 1: Add the New User

First, log in to your Ubuntu machine as the root user (or a user that already has sudo privileges). Open your terminal and run the following command to create a new user. Replace username with your desired account name:

adduser username

The system will prompt you to enter and confirm a strong password for the new user. You will also be asked for additional information (like Full Name and Room Number); you can simply press Enter to skip these fields.

Step 2: Add the User to the Sudo Group

By default, Ubuntu grants administrative privileges to any user who belongs to the sudo group. To add your newly created user to this group, execute the following command:

usermod -aG sudo username
  • -a stands for append.
  • -G specifies the group.

Step 3: Verify Sudo Privileges

To ensure the new user has been successfully granted sudo access, switch to the new account using the substitute user command:

su - username

Now, attempt to run a command with elevated privileges, such as updating the package list:

sudo apt update

You will be prompted to enter the new user’s password. If the command executes successfully, the user has been correctly configured with sudo privileges.

Leave a Reply

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

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.

Receive our best articles and tips delivered straight to your inbox.