How to Create and Manage Users in Ubuntu
Managing users is an essential task for administering a secure Ubuntu system. This guide walks you through creating users, setting passwords, assigning groups, and managing sudo privileges.
← BackStep 1: Create a New User
Use the adduser
command to create a new user:
sudo adduser username
Replace username
with your desired name. You’ll be prompted to set a password and enter optional details.
Step 2: Add User to the Sudo Group
If the user needs administrative privileges, add them to the sudo
group:
sudo usermod -aG sudo username
Step 3: Change a User's Password
To change the password for any user:
sudo passwd username
Step 4: List All Users
To view a list of all users on the system:
cut -d: -f1 /etc/passwd
Step 5: Delete a User
To remove a user and optionally delete their home directory:
sudo deluser username
sudo deluser --remove-home username
Step 6: Create and Manage Groups
Create a new group with:
sudo addgroup groupname
Add a user to a group:
sudo usermod -aG groupname username
Step 7: View User Group Membership
To see which groups a user belongs to:
groups username
Conclusion
Creating and managing users in Ubuntu helps you organize permissions and secure your system. Always give minimal access and only add users to the sudo group when necessary.
← Back