A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/linux-unix/users-in-linux-system-administration/ below:

Users in Linux System Administration

Users in Linux System Administration

Last Updated : 11 Jul, 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:

The useradd command is used to create a new user in Linux. Its basic syntax is:

Syntax:

useradd [options] USERNAME
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/passwdfile. 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:

  1. Superuser/root/administrator : Access to all the files on the system.
  2. Normal users : Limited access.

When a new user is created, by default system takes following actions:

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:

  1. Username field
  2. Password field
  3. The user ID number (UID)
  4. User's group ID number (GID)
  5. Additional information field such as the full name of the user or comment (GECOS)
  6. Absolute path of user’s home directory
  7. 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:

  1. User name field
  2. Password field
  3. Contains an encrypted password.
  4. Last Password Change
  5. The minimum number of days after which the user can change his password.
  6. Password validity
  7. Warning period
  8. Account validity
  9. Account disability

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.



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4