Open In App

User Management in Linux

Last Updated : 09 Jul, 2025
Summarize
Comments
Improve
Suggest changes
Share
Like Article
Like
Report

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
Awk-Command-to-List-Out-all-the-Users-in-Linux

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  

id-of-any-username

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  

Adding-a-user-in-linux

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  

assigning-a-password-to-the-user-in-linux

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 
Accessing-a-user-configuration-file

Now we will go through the commands to modify information. 

Modify User 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 

Changing-the-user-id-in-linux

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  

modifying-the-group-id-of-a-user-in-linux

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  

Changing-user-login-name-in-linux

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  

changing-home-directory-for-a-user-in-linux

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  

deleting-a-user-in-linux-forcefully

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.

5. Misconfigured Group Memberships

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.

7. Misconfigured User Management Files

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.


Article Tags :

Similar Reads