By default, Ubuntu locks the root user account for security reasons, preventing direct root logins. Instead, administrative tasks are performed using the sudo command, which grants temporary root privileges to regular users. This guide will walk you through creating a new user and granting them sudo privileges on Ubuntu 20.04 LTS.
Creating a User with Sudo Privileges
adduser command. Replace <username> with your desired username. You’ll be prompted to set a password and, optionally, provide additional user information.sudo adduser <username>

Since only users with administrative privileges can add new users, the sudo command is required here. This means your current user must already have sudo access to execute this command.
sudo group to grant sudo privileges. Members of this group can execute commands with root privileges by prefacing them with sudo.sudo adduser <username> sudo

The user is now part of the sudo group and has administrative privileges.
Join readers who trust AllThings.How
Add us as a preferred source on Google so our practical guides show up first next time you search.
Add to Google Preferences →Testing the Sudo User
su command followed by a hyphen and the username.su - <username>

After switching, you’ll notice the command prompt reflects the new username. Additionally, a welcome message may appear, indicating that the user can use sudo for administrative tasks.
tmp in the /etc directory.sudo mkdir /etc/tmp

You’ll be prompted to enter the new user’s password. If the command executes successfully, it confirms that the user has sudo privileges. You can verify the creation of the directory by listing the contents of /etc:
ls /etc
By completing these steps, you’ve successfully created a new user with sudo privileges on your Ubuntu 20.04 LTS system. If you ever need to revoke sudo access from this user, you can remove them from the sudo group using the deluser command:
sudo deluser <username> sudo






