Detailed Explanation of Linux System User and User Group Management

This article introduces the core knowledge of Linux user and user group management, aiming to achieve permission control and resource isolation. Users are categorized into root (UID 0, highest privilege), system users (UID 1-999, for running services), and ordinary users (UID ≥ 1000, for daily operations). Groups include primary groups (default ownership) and supplementary groups (additional memberships). Key configuration files: `/etc/passwd` stores user information (UID, GID, home directory, etc.), `/etc/group` stores group information (GID, members), and `/etc/shadow` stores encrypted passwords. Common commands: User management commands include `useradd` (-m to create home directory), `usermod` (-g to change primary group, -aG to add supplementary group), `userdel` (-r to delete home directory), and `passwd` (to set password); group management commands include `groupadd` and `groupdel`. Practical operation examples: Creating an ordinary user and adding them to a group, setting up a shared directory with the group ownership and assigning group read/write permissions. Note that for multi-user sharing, users should be in the same group, and when deleting a user while preserving files, manually clean the home directory after removing the user.

Read More