To create a new user with sudo privileges on Ubuntu, you can follow these steps:
- Connect to your Ubuntu server: You can connect via SSH or access the terminal directly if you're on the machine.
-
Open a terminal:
You can do this by pressing
Ctrl + Alt + T
or searching for "Terminal" in the application menu. -
Create the new user:
Use the
adduser
command to create a new user. Replacenewusername
with the desired username.sudo adduser newusername
You will be prompted to set a password and enter some additional information about the user. You can press
Enter
to leave any of these fields blank if you wish. -
Add the new user to the sudo group:
By default, the first user created during Ubuntu installation has sudo privileges. You can grant sudo privileges to the new user by adding them to the
sudo
group.sudo usermod -aG sudo newusername
-
Verify sudo privileges:
You can switch to the new user and verify that they have sudo privileges by running a command with
sudo
.su - newusername sudo ls /root
You will be prompted to enter the password for the new user. If everything is set up correctly, you should see the contents of the
/root
directory.
That's it! You've successfully created a new user with sudo privileges on Ubuntu. You can now use this user account to perform administrative tasks on the system.