Adding a user on Ubuntu - A Step-by-Step Guide
In Ubuntu, managing user accounts is a crucial aspect that defines system security and organization and is fundamental for customizing your computing experience. In this guide, we’ll explore the process of adding users on Ubuntu using the command-line interface.
Prerequisites
- A system running Ubuntu
- A user account with sudo privileges
- Access to a terminal window/command-line
- Basic knowledge of the command-line interface
Adding a user
To add a user on Ubuntu, you can use the adduser
command. This command creates a new user account and a home directory for the user. To add a user, open a terminal window and run the following command:
sudo adduser <username>
Replace <username>
with the desired username for the new user. After running the command, you will be prompted to set a password for the new user and provide additional information such as the user’s full name, room number, work phone, and home phone. You can skip these prompts by pressing Enter
to leave the fields blank.
Granting sudo privileges
By default, the new user will not have sudo privileges. To grant sudo privileges to the new user, you can add the user to the sudo
group using the usermod
command. Run the following command to add the user to the sudo
group:
sudo usermod -aG sudo <username>
Replace <username>
with the username of the new user. After running the command, the new user will have sudo privileges and will be able to execute commands with administrative privileges.
Extra: Deleting a user
If you ever need to delete a user account, you can use the deluser
command. To delete a user account, open a terminal window and run the following command:
sudo deluser <username>
Replace <username>
with the username of the user you want to delete. After running the command, you will be prompted to choose whether to delete the user’s home directory and mail spool. You can choose to delete or keep the user’s home directory and mail spool based on your preference.
Done!
That’s it! You’ve successfully added a new user on Ubuntu and granted them sudo privileges. You can now log in as the new user and enjoy a customized computing experience on your Ubuntu system.