User management is a core function of Linux system administration, aimed at controlling access and ensuring system security. Every user in Linux has a unique User ID (UID); UID 0 is reserved for the root user, 1–999 for system accounts, and 1000 onwards for regular users. Linux allows up to 60,000 users in a single directory, making it suitable for large-scale environments. Admins manage users by creating, modifying, and deleting accounts, setting permissions, and enforcing access policies. This ensures users can perform tasks without compromising system integrity.
In this article, we will discuss the key aspects of user management in Linux, including creating, modifying, and deleting user accounts, as well as handling common issues. We will also cover essential commands and files that help manage users and their access to system resources.
Types of Users in Linux
Linux is a multi-user operating system, meaning multiple users can access and operate the system simultaneously. Each user type serves a specific purpose and has different levels of access and control. Below are the main types of users you’ll encounter in Linux:
1. Root User
The root user is the most powerful user in Linux. This user can do anything on the system, like changing settings, installing or deleting software, and editing any file. It is used for important system tasks. A small mistake as root can affect the whole system.
2. Standard User
A standard user is a regular user with limited access. This user can use the system for everyday tasks like browsing the internet, creating files, and running applications. They cannot change system settings or view other users’ files without permission.
3. Sudo User
A sudo user is a normal user who is allowed to run some admin commands using the sudo
command. This helps in doing important tasks like installing software without giving full access like the root user.
4. System Account
System accounts are created for programs or services, not for people. They help run things like web servers or databases in the background. These accounts have limited permissions for safety.
5. Guest User
A guest user is a temporary account with very limited access. It is used when someone needs to use the system for a short time. Files or settings are not saved for this user.
6. User Groups
A user group is a collection of users. If you give permission to a group, all users in that group get the same access. This makes it easier to manage file and system permissions for many users at once.
User Management Files
These files are essential for managing users, groups, and permissions on a Linux system, and they play a key role in ensuring security and efficient system administration. The following are different user management files in linux:
1. /etc/passwd
This file stores basic information about all user accounts on the system. It includes the username, UID (User ID), GID (Group ID), home directory, default shell, and full name of each user.
2. /etc/shadow
This file securely stores encrypted user passwords along with details like the last password change date, password expiration time, and account expiration settings.
3. /etc/group
It defines all the user groups in the system. It contains the group name, GID (Group ID), and a list of users who are members of each group.
4. /etc/gshadow
This file stores secure group-related data, including encrypted group passwords, group administrators, and group members. It adds a layer of security to the /etc/group
file.
5. /etc/sudoers
This file controls who can use the sudo
command to run tasks with administrative privileges. It lists allowed users or groups and the commands or systems they can access.
6. /etc/login.defs
This file contains default settings for user account creation and password policies. It defines UID/GID ranges, password aging rules, and default paths for new user home directories.
7. /etc/skel/
This directory contains default configuration files that are automatically copied to a new user’s home directory when the account is created. It usually includes .bashrc
, .profile
, and other shell initialization files.
8. /var/log/auth.log
This log file records all authentication events, such as user logins, failed login attempts, use of the sudo
command, and account lock/unlock actions. It is important for system security and auditing.
User Account Management Commands
The below are some important user account management commands:
1. List all users
To list all the users in Linux, use the awk
command with the -F
option. This will access the /etc/passwd
file and print only the first column, which contains the usernames.
awk -F':' '{ print $1}' /etc/passwd

2. Get User ID
The id
command provides the user ID (UID) of any given username. This ID is also the group ID (GID) of the user by default.
id username
Example: id test

3. Add a User
The useradd
command creates a new user in the system. The user will be assigned an automatic ID based on the system's settings.
useradd username
Example: sudo useradd geeks

4. Assign a Password
The passwd
command is used to assign a password to the user. After entering the command, you will be prompted to input a new password for the user.
passwd username
Example: sudo passwd geeks

5. Accessing a User Configuration File
To view user details from the /etc/passwd
file, use the cat
command. This file contains user account information like UID, GID, home directory, and login shell.
cat /etc/passwd
This commands prints the data of the configuration file. This file contains information about the user in the format.
username : x : user id : user group id : : /home/username : /bin/bash

Now we will go through the commands to modify information.
System administrators often need to update user account settings. Below are common usermod
and userdel
commands used to modify user accounts.
1. Change User ID
To change the user ID (UID) of an existing user, use the usermod
command with the -u
option.
usermod -u new_id username
This command can change the user ID of a user. The user with the given username will be assigned with the new ID given in the command and the old ID will be removed.
Example: sudo usermod -u 1982 test

2. Change Group ID
To modify the group ID (GID) of a user or move a user to another group, use the usermod
command with the -g
option.
usermod -g new_group_id username
This command can change the group ID of a user and hence it can even be used to move a user to an already existing group. It will change the group ID of the user whose username is given and sets the group ID as the given new_group_id.
Example: sudo usermod -g 1005 test

3. Change Login Name
To change a user's login name, use the usermod
command with the -l
option.
usermod -l new_login_name old_login_name
Example: sudo usermod -c John_Wick John_Doe

4. Change Home Directory
To change a user's home directory, use the usermod
command with the -d
option. You can specify the new path for the home directory.
usermod -d new_home_directory_path username
Example: usermod -d new_home_directory test

5. Delete a User
The userdel
command removes a user from the system. Use the -r
option to also delete the user's home directory. If the user is part of any group, you must remove them from the group before deletion.
userdel -r username
Example: sudo userdel -r new_geeks

Common Issues in User Management in Linux
Managing users in Linux can present various challenges that impact system security and efficiency. The below are some common issues and strategies to address them:
1. Forgotten Passwords
Users may forget their passwords, leading to access issues.
Solution: Administrators can reset passwords using the passwd
command.
sudo passwd username
This command prompts for a new password, restoring user access.
2. Account Lockouts
Multiple failed login attempts can lock user accounts.
Solution: Unlock accounts using the usermod
command:
sudo usermod -U username
This command unlocks the specified user account.
3. Security Vulnerabilities
Outdated systems can be susceptible to security threats.
Solution: Keep the system updated with the latest patches using the package manager:
sudo apt update && sudo apt upgrade
Regular updates enhance system security.
4. Permission Errors
Incorrect file or directory permissions can restrict user access.
Solution: Adjust permissions using chmod
and chown
:
sudo chmod 755 /path/to/directory
sudo chown user:group /path/to/file
Proper permissions ensure appropriate access levels.
Users may lack necessary group memberships, limiting access.
Solution: Add users to groups with usermod
:
sudo usermod -aG groupname username
This command appends the user to the specified group.
6. Privilege Escalation Risks
Improper configurations can allow unauthorized privilege escalation.
Solution: Review and edit the /etc/sudoers
file carefully, preferably using visudo
to prevent syntax errors.
sudo visudo
Ensure only authorized users have elevated privileges.
Errors in critical files like /etc/passwd
and /etc/shadow
can disrupt user management.
Solution: Use commands like vipw
and vigr
to safely edit these files:
sudo vipw
sudo vigr
These commands lock the files during editing, preventing concurrent modifications.
Also read:
Conclusion
User management in Linux helps control who can access the system and what they can do. It involves creating, editing, and deleting user accounts, setting permissions, and managing user groups. Important files like /etc/passwd and /etc/shadow store user information, and commands like useradd
, usermod
, and userdel
are used to manage users. Common problems like forgotten passwords or account lockouts can be fixed with simple commands. Keeping the system updated and managing user permissions properly helps keep the system secure and running smoothly.
Similar Reads
File Management in Linux In Linux, most of the operations are performed on files. And to handle these files Linux has directories also known as folders which are maintained in a tree-like structure. Though, these directories are also a type of file themselves. Linux has 3 types of files: Regular Files: It is the common file
4 min read
Types of User Profile Management in LINUX User profile management is an essential topic in the profile management system, and it describes how the user can handle the profile. Various types of user-profiles management in Linux are - bashrcbash_profilebash_historybash_logoutbashrc Procedures Open the terminal and add the user.useradd t1Switc
1 min read
7 Linux Commands For Managing Users Linux is a fantastic platform that allows multi-user access options. Different users can access the same Linux OS for working simultaneously. A user account allows multiple people to access directories, terminals, the Internet, etc. There are three types of user accounts: User Account: This account
3 min read
Some time-saving tips for Linux Users Are you making most out of the Linux? There are lots of helpful features which appears to be time saving Tips and Tricks for many of Linux Users. Sometimes these time saving Tips and Tricks become the need. They help you to get productive with the same set of commands yet with enhanced functionality
4 min read
How to Remove Users from Groups in Linux? Groups in Linux are an important part of organizing the system's access control. Creating separate groups for separate types of roles of users allows the administrator to manage the access control of the Linux system efficiently. It is an essential skill to understand how to add, remove, and update
4 min read
How to Manage Directories in Linux? Directories in Linux or any operating system help to organize the data and files, which is then easier to find and manage. In this article, you will learn everything you will need to manage directories in Linux. We will try to cover every topic from creating, and copying to deleting the directories
6 min read