Managing users is one of the fundamental tasks when working with Linux.
Whether you’re setting up a server, managing a team, or just organizing your personal system, knowing how to add, modify, and remove users is essential.
Let’s walk through the basics in a straightforward and easy-to-follow way.
Table of Contents
- Understanding Users in Linux
- Viewing Users and Current Logins
- Creating a New User
- Modifying User Accounts
- Deleting Users
- Working with Groups
- Managing Permission
- Best Practices for User Management
- Conclusion
Linux is built to support multiple users, each with their own environment and permissions. Here are the main types of users:
• Root: The superuser with full control over the system
• Regular users: Standard accounts for everyday use
• System users: Special accounts used by system services,
usually without login access
Viewing Users and Current Logins
To see all users on your system, you can check the /etc/passwd file:
cat /etc/passwd
To find out who’s currently logged in:
Who
Adding a user is simple. You can use:
useradd (a quick way to create a user):
sudo useradd username
- Change password of the user sudo passwd username
adduser (more interactive, especially on Debian/Ubuntu):
sudo adduser username
This command will guide you through setting a password and other details
Sometimes you need to update user settings:
- Change a user’s home directory:
sudo usermod -d /new/home username
Add a user to a group (for example, the profilers group):
sudo usermod -aG sudo username
Change the default shell:
sudo usermod -s /bin/bash username
When a user no longer needs access, you can remove their account:
- Delete the user but keep their files:
sudo userdel username
- Delete the user and their home directory:
sudo userdel -r username
Groups help manage permissions for multiple users at once.
- Create a new group:
sudo groupadd groupname
- Add a user to a group:
sudo usermod -aG groupname username
Linux permissions control who can read, write, or execute files.
- Change permissions:
chmod u+x filename
- Change ownership:
sudo chown username:groupname filename
Best Practices for User Management
• Only give users the permissions they need
• Use groups to simplify permission management
• Encourage strong passwords and regular updates
• Regularly review user accounts and remove those no longer
needed
• Keep backups of important data
User management in Linux is straightforward once you get familiar with the key commands and concepts. With these tools, you can keep your system organized, secure, and running smoothly. Take your time exploring, and you’ll soon feel confident managing users like a pro.