Linux User Management Explained with Examples
User management is an essential part of a system administrator's job. A system administrator spends most of its time in managing user accounts. User account management includes three tasks. These tasks are creating new user accounts, updating existing user accounts, and deleting unnecessary user accounts.
Adding or creating user accounts
The useradd command adds a new user account. It requires a username as a compulsory argument. It uses the following syntax.
#useradd [options] username
Options are optional. They allow us to customize the user account properties. If we don't specify them, it uses their default values.

User management files
Linux uses four text files to save user accounts and related information. Each line in these files represents an account.
| File | Description |
| /etc/passwd | This file saves the username, user ID, primary group ID, user details, home directory, and default login shell. |
| /etc/shadow | This file saves encrypted passwords and related information. |
| /etc/group | This file saves groups and related information. |
| /etc/gshadow | This file saves group passwords. |

User's home directory
When we add a new user account, the useradd command creates a home directory for the user in the /home directory. Linux puts the user in this directory just after logging in.
Example
- Add a new user account.
- List the /home directory.
- Verify the user account gets its home directory in it.

By default, all users get a home directory in the /home directory. The -d option allows us to customize the home directory location.
Example
- Add a new user account.
- Use the -d option and set the home directory path to the /[username] directory.
- Verify the user account gets its home directory on the custom location.

User profile files
Profile files customize the shell environment and control the login and logout processes. The user's home directory saves profile files. When we add a new user account, Linux copies these files from the /etc/skel directory to the user's home directory.
Example
- Add a new user account and check its home directory.
- List the /etc/skel directory.
- Verify the user's home directory gets all profile files from the default skeleton directory.

The /etc/skel directory contains the default user profile files. Instead of default user profile files, if you want to assign custom profile files to a user account, use the -k option. The -k option works with the -m option.
Example
- Make a new directory and copy all contents from the /etc/skel directory.
- Add a prefix test to all contents.
- Add a new user account.
- Use the -m and -k flags.
- Specify the new skeleton directory path as the argument.
- List the user's home directory and verify it gets all custom profile files.

Creating/changing the user password
The useradd command only adds the new user account. It does not create a password for the user account. The newly created user account remains locked until we assign a password to it. The passwd command assigns the password.
Example
- Add a new account.
- Switch to a CLI virtual console.
- Use the new account to log in.
- The login process will fail.
- Assign a password to the user account.
- Log in again.
- The login process will allow the user to log in.

Adding description to user accounts
The -c allows us to add a description to the user account. We can use this option to save the user's full name and other related information, such as designation or phone number.
Example
- Add a new user account.
- Use the -c option to add a description.
- In the description, set the full name 'RedHat Student 1'.
- Verify the description saved in the user detail field of the user entry in the /etc/passwd file.

Adding user accounts with custom groups
The -g option allows us to customize the user's primary group. By default, it creates a new group and selects it as the user's primary group. It chooses the group name to be the same as the user name.
Example
- Add a new user account.
- Check its primary group.
- Add a new group named demogroup.
- Add a new user.
- Use the -g option and make the demogroup as the primary group.
- Verify the new user gets the custom primary group.

Creating user accounts with the custom shell
The /bin/bash is the default shell. If we want to assign a different shell to a user account, we need to use the -s option. The -s option allows us to customize the default shell.
Example
- Add a new user account.
- Check its default shell.
- Add a new user account.
- Use the -s option and set the /bin/sh as the default shell.
- Verify the custom shell.

Deleting user accounts
The userdel command deletes a user account. It removes the user account's entry from all configuration files. However, it does not delete the user's home and mail directories. These directories contain the user data.

If you want to remove these directories along with the user account, use the -r option.
Example
- Delete a user account from the accounts we created in the above exercises.
- Check the deleted user account's home and mail directories. They will present.
- Delete another user account using the -r option.
- Check the deleted user account's home and mail directories.
- The command will delete all directories related to the user.

This tutorial is part of the tutorial series 'Linux User and Group Management Explained with Examples'. Other parts of this series are the following.
Chapter 01 Difference between the root user and super (sudo) user
Chapter 02 Linux User Management Explained with Examples
Chapter 03 Linux Group Management Explained with Examples
Chapter 04 Password aging policy Explained with chage command
Chapter 05 The /etc/group File Explained
Chapter 06 The /etc/gshadow File Explained
Chapter 07 The /etc/passwd file in Linux Explained with Examples
Chapter 08 The /etc/shadow file in Linux Explained with Examples
Chapter 09 The useradd command Explained
Chapter 10 The gpasswd command Explained
Chapter 11 The chage command Examples and Usages
Conclusion
Linux user management includes three main tasks: adding user accounts, managing existing user accounts, and deleting unwanted user accounts. The useradd command adds new user accounts. The usermod command updates existing user accounts. The userdel command deletes unnecessary user accounts.
By ComputerNetworkingNotes Updated on 2026-04-07