Users in Linux System Administration
Last Updated :
05 Mar, 2025
User management is one of the fundamental tasks in Linux systems administration because a user has to go through a series of access controls to keep an environment secure and organized. It provides functionalities that include adding, modifying, and deleting user accounts, assigning privileges, and setting password policies. One must know how to manage users to keep the system secure and efficient.
What is Users in Linux System Administration?
In Linux system administration, a user is an individual or system entity that can log in and access the system. Users in Linux are managed through unique accounts with assigned User IDs (UIDs), permissions, and roles.
Types of Users in Linux:
- Root User (Administrator) – The superuser with full control over the system, identified by UID
0
. - Regular Users – Non-administrative users created for daily operations assigned unique UIDs.
- System Users – Users created by the system for running services like databases and web servers (e.g.,
www-data
, mysql
).
The useradd command is used to create a new user in Linux. Its basic syntax is:
Syntax:
useradd [options] USERNAME
- USERNAME: The name of the user to be created.
- [options]: Additional parameters to customize the creation process.
Useful Linux Commands for User Management
In Linux, user management is crucial for system security, access control, and permissions.
Command | Description | Syntax & Example |
---|
adduser | Create a new user in Linux. | sudo adduser username Example: sudo adduser john |
useradd | Another command to add a new user (without creating a home directory). | sudo useradd username Example: sudo useradd mike |
passwd | Set or change a user’s password. | sudo passwd username Example: sudo passwd john |
deluser | Remove a user from the system. | sudo deluser username Example: sudo deluser mike |
userdel | Another command to delete a user but doesn’t remove the home directory by default. | sudo userdel username Example: sudo userdel mike |
usermod | Modify user account properties, such as username, home directory, or groups. | sudo usermod -l newname oldname Example: sudo usermod -l david john |
id | Display user ID (UID) and group ID (GID) information. | id username Example: id john |
whoami | Show the currently logged-in user. | whoami |
who | List all users currently logged into the system. | who |
w | Show logged-in users and their activity. | w |
last | Display login history of users. | last |
groups | Show groups a user belongs to. | groups username Example: groups john |
groupadd | Create a new user group. | sudo groupadd groupname Example: sudo groupadd developers |
groupdel | Delete a group. | sudo groupdel groupname Example: sudo groupdel developers |
usermod -aG | Add a user to a group. | sudo usermod -aG groupname username Example: sudo usermod -aG sudo john |
chage | Set or check password expiry details for a user. | sudo chage -l username Example: sudo chage -l john |
getent passwd | List all users on the system. | getent passwd |
awk -F: | Display only the usernames of all users. | awk -F: '{print $1}' /etc/passwd |
compgen -u | Show all system users. | compgen -u |
sudo visudo | Edit sudo privileges for users. | sudo visudo |
`who | wc -l` | Count the number of currently logged-in users. |
Basic useradd Command Example in Linux System Administration
Without any options, the simplest use of the useradd command looks like this:
sudo useradd <username>
This creates a user with the default settings.
Users are accounts that can be used to login into a system. Each user is identified by a unique identification number or UID by the system. All the information of users in a system are stored in /etc/passwd
file. The hashed passwords for users are stored in /etc/shadow
file. Users can be divided into two categories on the basis of the level of access:
- Superuser/root/administrator : Access to all the files on the system.
- Normal users : Limited access.
When a new user is created, by default system takes following actions:
- Assigns UID to the user.
- Creates a home directory
/home/
. - Sets the default shell of the user to be
/bin/sh
. - Creates a private user group, named after the username itself.
- Contents of
/etc/skel
are copied to the home directory of the new user. - .bashrc, .bash_profile and .bash_logout are copied to the home directory of new user.These files provide environment variables for this user’s session.
1. Description of contents of /etc/passwd File
This file is readable by any user but only root as read and write permissions for it. This file consists of the following colon separated information about users in a system:
- Username field
- Password field
- An `x` in this field denotes that the encrypted password is stored in the /etc/shadow file.
- The user ID number (UID)
- User's group ID number (GID)
- Additional information field such as the full name of the user or comment (GECOS)
- Absolute path of user’s home directory
- Login shell of the user
Syntax:
[username]:[password]:[UID]:[GID]:[GECOS]:[home_dir]:[shell_path]
Example:

2. Description of contents of the /etc/shadow File
This file is readable and writable by only by root user. This file consists of the following colon separated information about password of users in a system:
- User name field
- Password field
- Contains an encrypted password.
- A blank entry, {:: }, indicates that a password is not required to login into that user’s account.
- An asterisk, {:*:}, indicates the account has been disabled.
- Last Password Change
- This field denotes the number of days since the date of last password change counted since UNIX time (1-Jan-1970).
- The minimum number of days after which the user can change his password.
- Password validity
- Denotes the number of days after which the password will expire.
- Warning period
- Denotes the number of days before the password expiry date, from which the user will start receiving warning notification for password change.
- Account validity
- Denotes the number of days after which the account will be disabled, once the password is expired.
- Account disability
- This field denotes the number of days since which the account had been disabled counted from UNIX time (1-Jan-1970).
Syntax:
[username]:[enc_pwd]:[last_pwd_change]:[pwd_validity]:[warn_date]:[acc_validity]:[acc_disablity]
Example:

Common Options Used with the useradd Command in Linux System Administration
Option | Description |
---|
-m | Create the user’s home directory. |
---|
-d | Specify a custom home directory. |
---|
-s | Define the user’s default shell. |
---|
-G | Add the user to additional groups. |
---|
-e | Set an expiration date for the user account. |
---|
-c | Add a comment (typically the full name of the user). |
---|
Detailed Explanation of useradd Options
1. -m Option (Create Home Directory)
By default, useradd does not create a home directory. Use the -m option to ensure the user gets a home directory:
sudo useradd -m kavya
2. -d Option (Custom Home Directory)
To assign a non-default home directory, use the -d option:
sudo useradd -d /custom/home kavya
3. -s Option (Specify Default Shell)
Set a specific shell for the user with the -s option:
sudo useradd -s /bin/bash kavya
This sets Bash as the user's default shell.
4. -G Option (Add User to Groups)
To add a user to additional groups, use the -G option:
sudo useradd -G sudo,developers kavya
5. -e Option (Set Expiration Date)
To set an expiration date for a user account:
sudo useradd -e 2024-12-31 kavya
This sets the account to expire at the end of 2024.
Conclusion
User management is one of the cardinal aspects in Linux system administration. It ensures proper resource allocation and keeps your system secure. The useradd command and all of its options give the administrator an in-depth way to create and edit user accounts according to their needs. Knowing how to use them would vastly simplify user administration for accommodating user environments, access levels, and even policy enforcements. The system administrator will be able to maintain the Linux environment secure, productive, and organized with the usage of universal commands such as useradd.
Similar Reads
Linux Commands Cheat Sheet Linux, often associated with being a complex operating system primarily used by developers, may not necessarily fit that description entirely. While it can initially appear challenging for beginners, once you immerse yourself in the Linux world, you may find it difficult to return to your previous W
13 min read
Linux/Unix Tutorial Linux is one of the most widely used open-source operating systems. It's fast, secure, stable, and powers everything from smartphones and servers to cloud platforms and IoT devices. Linux is especially popular among developers, system administrators, and DevOps professionals.Linux is:A Unix-like OS
10 min read
25 Basic Linux Commands For Beginners [2025] While performing a task, we all need shortcuts. Shortcuts help us to complete a task quickly. Linux comes with such commands which are one to two words, using that commands, you can perform several operations in no time. As a beginner, you must be aware of those basic Linux commands to complete an o
13 min read
grep command in Unix/Linux The grep command is one of the most useful tools in Linux and Unix systems. It is used to search for specific words, phrases, or patterns inside text files, and shows the matching lines on your screen. Syntax of grep Command in Unix/LinuxThe basic syntax of the `grep` command is as follows:grep [opt
6 min read
Sed Command in Linux/Unix With Examples The SED command (short for Stream Editor) is one of the most powerful tools for text processing in Linux and Unix systems. It's commonly used for tasks like search and replace, text transformation, and stream editing.With SED, you can manipulate text files without opening them in an editor. This mak
8 min read
AWK command in Unix/Linux with examples Awk is a scripting language used for manipulating data and generating reports. The awk command programming language requires no compiling and allows the user to use variables, numeric functions, string functions, and logical operators. Awk is a utility that enables a programmer to write tiny but eff
8 min read
Introduction to Linux Shell and Shell Scripting If we are using any major operating system, we are indirectly interacting with the shell. While running Ubuntu, Linux Mint, or any other Linux distribution, we are interacting with the shell by using the terminal. In this article we will discuss Linux shells and shell scripting so before understandi
8 min read
How to Find a File in Linux | Find Command The find command in Linux is used to search for files and directories based on name, type, size, date, or other conditions. It scans the specified directory and its sub directories to locate files matching the given criteria.find command uses are:Search based on modification time (e.g., files edited
9 min read
ZIP command in Linux with examples In Linux, the zip command compresses one or more files or directories into a single.zip archive file. This saves disk space, keeps data organized, and makes it simple to share or backup files. It's among the most used compression utilities, particularly when sharing large files via email or storing
6 min read
What is Linux Operating System The Linux Operating System is a type of operating system that is similar to Unix, and it is built upon the Linux Kernel. The Linux Kernel is like the brain of the operating system because it manages how the computer interacts with its hardware and resources. It makes sure everything works smoothly a
13 min read