Operations 16 min read

Master Linux User & Group Management: Commands, Files, and Best Practices

This comprehensive guide explains Linux user and group management, covering essential files such as /etc/passwd, /etc/shadow, and /etc/group, detailing each field, and providing step‑by‑step command examples for adding, modifying, locking, and deleting users and groups, as well as managing passwords and group administrators.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
Master Linux User & Group Management: Commands, Files, and Best Practices

Overview

Linux is a multi‑user, multitasking operating system where each user must have an account. Accounts allow administrators to track usage, control resource access, and provide security.

User Management Files

/etc/passwd

This file stores basic user attributes; it is world‑readable. Each line contains seven colon‑separated fields: username, password placeholder, UID, GID, comment, home directory, and login shell.

/etc/shadow

Contains encrypted passwords; only root can read it. Fields include login name, encrypted password, last change date, minimum and maximum age, warning period, inactivity period, and expiration date.

/etc/group

Defines groups; format similar to /etc/passwd with fields: group name, password placeholder, GID, and member list.

User Management Commands

1. Add User (useradd)

Creates a new user. Common options: -c (comment), -d (home directory), -m (create home), -e (expire date), -g (primary group), -G (supplementary groups), -s (login shell), -u (UID), -p (encrypted password).

2. Modify User (usermod)

Changes user attributes such as login name (-l), home directory, group membership, or locks the account (-L). Unlock with -U.

3. Delete User (userdel)

Removes a user; -r also removes the home directory.

4. Set Password (passwd)

Root can set or change any account password; users can change their own.

5. Lock/Unlock Password

Use passwd -l to lock and passwd -u to unlock; check status with passwd -S.

6. Group Management

Create groups with groupadd, modify with groupmod (rename with -n, change GID with -g), and delete with groupdel. Use usermod or gpasswd to add or remove users from groups, and assign group administrators.

Additional utilities such as id, whoami, and groups display user and group information.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

LinuxSystem AdministrationUser Managementgroup-managementcommands
MaGe Linux Operations
Written by

MaGe Linux Operations

Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.