How to Manage Users and Permissions in Linux
Linux is known for its robust multi-user architecture and permission system, which makes it ideal for both desktop and server environments. Understanding how to manage users and permissions is fundamental for maintaining security, ensuring proper access control, and efficiently administering a Linux system. This guide will take you through everything from user creation to setting and modifying permissions, group management, and using advanced tools like chmod, chown, and usermod. Whether you’re a beginner or looking to enhance your system administration skills, this article will give you a comprehensive understanding.

Understanding the Linux User Model
Linux is a multi-user system, meaning multiple people can use the same machine simultaneously or at different times, each with their own account and permissions.
Types of Users:
- Root User: The superuser with unrestricted access to all commands and files.
- Regular Users: Created by system admins or users themselves (depending on system policy).
- System Users: Used for running background services (e.g.,
www-datafor web servers).
Each user is identified by:
- Username
- UID (User ID)
- GID (Group ID)
- Home directory
- Shell
Creating and Managing Users
Add a New User
sudo adduser john
This command creates a new user named john, sets up a home directory, and prompts for a password.
Set or Change a User’s Password
sudo passwd john
Delete a User
sudo deluser john
sudo deluser –remove-home john # Also deletes home directory
Managing Groups
Groups allow you to organize users and manage permissions collectively.
Create a Group
sudo addgroup developers
Add User to a Group
sudo usermod -aG developers john
-aG means append the user to the supplementary group.
Remove a User from a Group
There’s no direct command to remove from a group; instead, edit the group file:
sudo gpasswd -d john developers
View Groups
groups john
File and Directory Permissions
Linux files and directories have three types of permissions:
- Read (r) – View contents
- Write (w) – Modify contents
- Execute (x) – Run as a program or script
These permissions are assigned to:
- Owner
- Group
- Others
Viewing Permissions
ls -l filename
Example Output:
-rwxr-xr– 1 john developers 1024 May 10 10:00 script.sh
Breakdown:
johnis the ownerdevelopersis the group-rwxr-xr--means:- Owner has read, write, execute
- Group has read and execute
- Others have read only
Changing File Permissions
Using chmod
You can change permissions using symbolic or numeric modes.
Symbolic Mode:
mod u+x script.sh # Add execute permission for the user
chmod g-w script.sh # Remove write permission from group
Numeric Mode:
Permissions are expressed as 3 digits:
- Read = 4
- Write = 2
- Execute = 1
Sum of these for each type (owner/group/others):
chmod 755 script.sh
755 = rwxr-xr-x
Changing Ownership
Using chown
sudo chown john:developers script.sh
This sets john as the owner and developers as the group.
You can also recursively change ownership:
sudo chown -R john:developers /home/john/
Special Permission Bits
SetUID
When SetUID is set on an executable, users run it with the permissions of the file owner.
chmod u+s file
SetGID
Files inherit the group of the directory they’re created in.
chmod g+s directory
Sticky Bit
Prevents users from deleting others’ files in a shared directory (like /tmp).
chmod +t /shared-folder
Managing User Environment
Each user has a home directory containing config files such as:
.bashrc.profile
These control startup behavior, shell preferences, and more.
To customize a user’s environment:
echo “alias ll=’ls -lah'” >> /home/john/.bashrc
Monitoring and Managing Users in Real Time
List Logged-In Users
who
w
Switch to Another User
su – john
Lock and Unlock User Accounts
sudo usermod -L john # Lock
sudo usermod -U john # Unlock
Conclusion
Effective user and permission management is key to maintaining a secure and organized Linux environment. By mastering user creation, group management, and file permission settings, you can control who has access to what, minimize risks, and ensure that your system remains both functional and secure. Whether you’re managing a single desktop or a multi-user server, these foundational concepts are indispensable. Continue experimenting and practicing with the commands covered here to become proficient in Linux administration.
Best Practices
- Use groups to manage permissions instead of setting them per-user.
- Avoid using the root account for daily tasks.
- **Use **
sudoto temporarily gain root access. - Regularly audit user accounts with
last,who, andid. - Use strong, unique passwords for each user.
- **Keep an eye on the
/etc/passwd,/etc/shadow, and **/etc/groupfiles.
