Linux User Management: Users, Groups, Creation, Modification, and Password Operations
This article explains Linux user and group management, detailing the structure of /etc/passwd and /etc/shadow, user classifications, commands for creating, viewing, modifying, and deleting users, as well as password handling and related security considerations.
Linux is a multi‑user, multitasking operating system, and managing users and groups is essential for authentication, authorization, and auditing. This guide introduces Linux user concepts, explains how user information is stored in /etc/passwd and /etc/shadow, and describes each field in these files.
The /etc/passwd file contains seven colon‑separated fields per line: username, password placeholder, UID, GID, user description, home directory, and default shell. The /etc/shadow file holds nine fields, including the encrypted password, last password change date, minimum and maximum password age, warning period, inactivity period, account expiration, and a reserved field.
Linux defines three user types: the superuser (UID 0, e.g., root), regular users (UID 500‑6000 on CentOS 6), and pseudo‑users (UID 1‑499) that cannot log in and are used for system tasks.
To create users, the useradd (or its symlink adduser) command is used. The basic syntax is useradd [options] username. Common options are illustrated with an example that creates a user dev1 in group dev with an additional group test: useradd -g dev -G test dev1 Viewing user information can be done with various commands: w and who show currently logged‑in users; id username displays a specific user's UID/GID; the entire /etc/passwd file or awk -F : '{print $1}' /etc/passwd lists all users; last and lastb show successful and failed login records respectively.
Password management uses the passwd command. Its options allow setting expiration, locking accounts, etc. For example, locking the user wuwei so they cannot change their password is done with: passwd -l wuwei Attempting to change the password for a locked account results in the error “passwd: Authentication token manipulation error”.
Modifying existing users is performed with usermod. The syntax is usermod [options] username. An example adds the supplementary group mysql to user dev1: usermod -G mysql dev1 To delete a user, the userdel command is used with the format userdel [options] username.
Overall, the article provides a comprehensive reference for Linux user and group administration, covering file structures, user categories, creation, inspection, password handling, modification, and removal.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
360 Tech Engineering
Official tech channel of 360, building the most professional technology aggregation platform for the brand.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
