Linux User and Group Management Fundamentals

User Types in Linux

Single-User Multi-Tasking

A single user can log in and execute multiple tasks simultaneously. For example, a user can browse the web while listening to music and running background processes.

Multi-User Multi-Tasking

Multiple users can operate the system concurrent with separate tasks. For instance, the apache user handles web services while the root user performs system administration, all operating independent.

User Role Classification

Users are categorized by their roles, identified through UID and GID values. The UID serves as the unique identifier for each system account.

  • Superuser: The root account with UID and GID 0, possessing full system access and administrative privileges. For security reasons, direct root SSH access is often disabled in production environments.
  • Regular Users: Accounts created by system administrators for normal system usage.
  • System Users: Default accounts created during system installation that cannot log in directly. These accounts (e.g., bin, adm, nobody) are essential for proper system operation and process management.

Multi-user systems enhance both convenience and security by isolating user environments and permissions.

User and Group Configuration Files

Core Configuration Files

System user and group information is stored in four primary files:

  • /etc/passwd - User account definitions
  • /etc/shadow - Encrypted password information
  • /etc/group - Group definitions
  • /etc/gshadow - Group password and administration data

/etc/passwd File Structure

Each line defines a user account with colon-separated fields:

username:password:UID:GID:description:home_directory:login_shell

Example entry:

root:x:0:0:root:/root:/bin/bash

UID Range Specifications

  • 0: Superuser (root)
  • 1-499: System-reserved UIDs
  • 500-65535: Regular user UIDs

File permissions:

  • /etc/passwd: 644 (readable by all)
  • /etc/shadow: 400 (root access only)

/etc/shadow File Format

Contains nine colon-separated fields:

username:encrypted_password:last_change:min_days:max_days:warn_days:inactive:expire:reserved

Group Configuration Files

  • /etc/group format: group_name:password:GID:member_list
  • /etc/gshadow format: group_name:encrypted_password:administrators:member_list

User Management Commands

User Management Utilities

useradd/adduser    # Create new user accounts
passwd             # Set or modify user passwords
usermod            # Modify existing user properties
id                 # Display user UID, GID, and group memberships
su                 # Switch user identity
sudo               # Execute commands with elevated privileges
visudo             # Edit sudo configuration safely
pwck               # Validate password file integrity
chfn               # Change user finger information
finger             # Display user information

Group Management Utilities

groupadd    # Create new groups
groupdel    # Remove existing groups
groupmod    # Modify group properties
groups      # Show user's group memberships
grpck       # Verify group file consistency
grpconv     # Synchronize group and gshadow files
grpunconv   # Convert gshadow back to group format

User Environment Configuraton

/etc/skel Directory

This directory contains template files copied to new user home directories during account creation. Default files include hidden configuration files for shell environments.

Example skeleton contents:

$ ls -la /etc/skel/
total 24
drwxr-xr-x.  3 root root 4096 Jun 24 03:12 .
drwxr-xr-x. 85 root root 4096 Jul  2 03:43 ..
-rw-r--r--.  1 root root   18 Jul 18 2013 .bash_logout
-rw-r--r--.  1 root root  176 Jul 18 2013 .bash_profile
-rw-r--r--.  1 root root  124 Jul 18 2013 .bashrc
drwxr-xr-x.  2 root root 4096 Nov 12 2010 .gnome2

When creating a new user:

useradd newuser    # Copies /etc/skel/ contents to /home/newuser/

/etc/login.defs Configuration

Defines default parameters for user creation:

MAIL_DIR        /var/spool/mail    # User mail directory
PASS_MAX_DAYS   99999              # Maximum password validity
PASS_MIN_DAYS   0                  # Minimum days between password changes
PASS_MIN_LEN    5                  # Minimum password length
PASS_WARN_AGE   7                  # Warning period before password expiry
UID_MIN         500                # Starting UID for regular users
UID_MAX         60000              # Maximum UID for regular users
CREATE_HOME     yes                # Create home directory automatically
UMASK           077                # Default home directory permissions
USERGROUPS_ENAB yes                # Remove group when deleting user
ENCRYPT_METHOD  SHA512             # Password encryption algorithm

/etc/default/useradd Settings

Default parameters for useradd command:

GROUP=100                    # Default group ID
HOME=/home                  # Parent directory for user homes
INACTIVE=-1                 # Account inactivation setting
EXPIRE=                     # Account expiration date
SHELL=/bin/bash             # Default login shell
SKEL=/etc/skel              # Skeleton directory path
CREATE_MAIL_SPOOL=yes       # Create mail spool for new users

Practical User Management

User Creation with useradd

When executed without options, useradd reads configuration from /etc/login.defs and /etc/default/useradd, creates entries in password and group files, generates shadow records, and sets up the user's home directory.

Common useradd options:

-c comment       # Account description
-d home_dir      # Specify home directory
-e expire_date   # Account expiration date
-f inactive_days # Days before inactivation after expiry
-g initial_group # Primary group assignment
-G supplementary_groups # Additional group memberships

Group Creation with groupadd

groupadd [-g gid] [-r] [-f] groupname

Options:

  • -g gid: Specify group ID (must be unique)
  • -r: Create system group (GID below UID_MIN)
  • -f: Force creation, overwriting existing group

Password Management with passwd

Root can set any user's password, while regular users can only change their own. Common options:

-d    # Delete user password (root only)
-l    # Lock user account (root only)
-u    # Unlock user account (root only)
-x days # Maximum password validity period
-n days # Minimum days between changes
-w days # Warning period before expiry
-i days # Inactivation period after expiry
-S    # Display password status

Non-interactive password setting:

echo "newpassword" | passwd --stdin username

Password Aging with chage

Modify password expiration policies:

chage -d last_day username     # Set last password change date
chage -E expire_date username  # Set account expiration
chage -l username             # Display aging information
chage -m min_days username    # Set minimum days between changes

User Modification with usermod

Modify existing user properties:

usermod -c "New Description" username    # Change user description
usermod -d /new/home -m username         # Relocate home directory
usermod -e YYYY-MM-DD username          # Set account expiration
usermod -s /bin/tcsh username           # Change login shell

Account Deletion with userdel

Remove user accounts and associated files:

userdel username          # Remove user account only
userdel -r username       # Remove user and home directory

Tags: Linux user-management group-management system-administration permissions

Posted on Fri, 30 Oct 2026 16:49:15 +0000 by brianjw