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 + Tor searching for "Terminal" in the application menu. -
Create the new user:
Use the
addusercommand to create a new user. Replacenewusernamewith the desired username.sudo adduser newusernameYou will be prompted to set a password and enter some additional information about the user. You can press
Enterto 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
sudogroup.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 /rootYou will be prompted to enter the password for the new user. If everything is set up correctly, you should see the contents of the
/rootdirectory.
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.