Manage user accounts and groups with usermod and groupmod
Linux account administration is a graph of names, numeric IDs, home directories, and group memberships. A small edit can affect SSH access, cron jobs, file ownership, or an application that runs under the account. The local tools usermod and groupmod handle these relationships cleanly when changes are planned and verified.
usermod modifies user records, while groupmod modifies group records. On RHEL, CentOS Stream, and Fedora systems, both edit the local account records while leaving file contents and running processes alone. That distinction matters when a Sydney administrator changes an account used by a service in Melbourne.
Plan a controlled identity change
Begin with getent passwd alice, getent group wheel, and id alice, because getent follows the configured name-service sources. Record the login shell, UID, primary GID, supplementary groups, home directory, and expiry state with chage -l alice before changing anything. Keep a configuration backup and use a maintenance window when the account belongs to a critical application.
For an Australian organisation, a written change window is worth the extra minute. If a support lead says a contractor needs access “this arvo”, capture the exact time and time zone instead of relying on the informal deadline. The authorised administrator should also note whether a service account is local, directory-managed, or shared with another team.
Separate service accounts from interactive users
Keep human and software identities separate. Give a service account such as backup a dedicated non-login shell and review every key or credential assigned to it. Confirm the target path with command -v nologin, then use sudo usermod -s /usr/sbin/nologin backup where that path exists. Locking a password with usermod -L does not necessarily stop SSH public-key authentication, so verify both paths.
Changing a name, UID, or shell does not change network settings. For an appliance with a fixed address, follow the static IP configuration procedure separately and keep its nmcli profile, hostname, and service account in the same change record.
Add and remove supplementary groups safely
Supplementary groups grant access through group-owned files and directories. Add an account to wheel and deploy with sudo usermod -aG wheel,deploy alice, then inspect the result using id alice. The -a option appends memberships and preserves existing ones, which is essential for accounts with access to several application groups.
Omit -a and -G replaces the supplementary group list, potentially removing access needed by scheduled jobs. Use groups alice for a quick view, but test with a fresh login because existing shells keep the group set they received at sign-in. newgrp can alter a current session, yet it does not update the stored account.
To remove one membership, use sudo usermod -G wheel alice only when wheel is the complete intended supplementary list, or use gpasswd -d alice wheel to remove the user from that group without replacing the others.
Compare common account operations
These are the routine operations and the behaviour to check:
| Account need | Command | Behaviour to check |
|---|---|---|
| Add a supplementary group | sudo usermod -aG deploy alice |
Appends deploy and retains existing memberships. |
| Change a primary group | sudo usermod -g appusers alice |
Changes the primary GID used for new files. |
| Rename a group | sudo groupmod -n operations platform |
Changes the group name but retains its GID. |
| Change a group ID | sudo groupmod -g 1500 platform |
Existing files retain the old GID. |
| Lock a password | sudo usermod -L alice |
Blocks password authentication; check SSH keys separately. |
usermod acts on user records, while groupmod acts on group records. Neither rewrites files that already carry a different UID or GID. Run one narrow change at a time, inspect its exit status, and use getent or id to confirm the stored result before moving to the next account.
Keep an authenticated emergency session open while changing remote accounts, then open a fresh user session to test group access. This protects against locking out the only administrative path.
Rename groups without losing file access
groupmod -n is usually safer than changing a numeric group ID because files owned by that GID keep working after a rename. A GID change does not travel through the filesystem: files retain the old number, and each user’s primary GID in /etc/passwd needs separate attention with usermod -g. Confirm the final mapping with getent group and getent passwd.
For Apache or Nginx deployments, the web server tutorials category is useful for checking the web user, document root, and permissions together. Verify the complete path with namei -l, remember that running workers keep old supplementary groups, and on SELinux systems inspect labels with ls -Z before changing modes.
Close out account changes with evidence
Record each change with the exact command, old values, new values, operator, and verification result. Recheck home ownership, the primary GID, sudo -l -U alice access, active sessions, and application-specific file access. If a directory or service breaks, restore the prior record rather than stacking compensating changes onto an unclear state.
Australian managed-service providers commonly support on-premises RHEL or CentOS Stream estates in Brisbane and Perth while cloud identities are administered through Microsoft Entra ID. Local usermod changes do not reliably persist for directory-managed accounts; use the identity platform for those and keep the local command for local service identities. A task board such as project planning tools can carry the account inventory, approval, and maintenance-window result into one auditable workflow.
The practical takeaway is controlled, evidenced change: capture the state before the edit, run one command, verify it in a fresh login, and confirm that access and ownership still match the service requirement.