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
What is Linux System Administration? Linux System Administration involves managing the operations of a Linux-based computer system. System administrators (or sysadmins) are the gatekeepers of the IT infrastructure, ensuring that all related hardware and software work reliably and securely. In this article, you will go through the basic
6 min read
Groups in Linux System Administration Each group in a Linux system is uniquely identified by a group identification number or GID. All the information listing groups in a system are stored in /etc/group file. The hashed passwords for groups are stored in /etc/gshadow file. Every user has a primary user group and zero or more supplementa
2 min read
Beginner's Guide to Linux System Administration A Linux System Administrator manages the operations such as maintaining proper software, observing them, and even taking care of backup and hardware systems. It is recommended that before reading this article please go through the article What is Linux System Administration. Here we have some basics
5 min read
Introduction to Webmin: Web-based Linux System Administration Linux system administration can be a difficult task, especially for beginners. Command-line interfaces are powerful tools for managing Linux systems, on the other hand, they can also be complex to operate on. When it comes to GUIs, we have a Web-based solution that simplifies the management of Linux
5 min read
How to Grant Admin Privileges to a User in Linux Linux is an operating system that is open source operating system. There are many distros available in Linux distribution like Ubuntu, Kali Linux, Arch Linux, and Red Hat Linux. In this article, we will understand how to give admin privileges to non-admin users in the Ubuntu Operating system. Introd
5 min read