Linux usermod Guide - ryzendew/Linux-Tips-and-Tricks GitHub Wiki
Linux usermod Guide
Complete beginner-friendly guide to usermod on Linux, covering Arch Linux, CachyOS, and other distributions including modifying users, changing user properties, and user account management.
Table of Contents
Understanding usermod
What is usermod?
usermod modifies existing user accounts.
Uses:
- Change properties: Modify user settings
- Add groups: Add user to groups
- Change shell: Update default shell
- Lock/unlock: Disable/enable accounts
Why it matters:
- User management: Update user accounts
- Permissions: Modify user access
- Configuration: Change user settings
Modifying Users
Change Shell
Update shell:
# Change user shell
sudo usermod -s /bin/zsh username
# Change to fish
sudo usermod -s /usr/bin/fish username
Change Home Directory
Move home:
# Change home directory
sudo usermod -d /new/home/username -m username
# -m moves files
User Properties
Change UID
Update user ID:
# Change UID
sudo usermod -u 1001 username
# Update file ownership
sudo find /home/username -user old-uid -exec chown username {} \;
Change GID
Update group:
# Change primary group
sudo usermod -g groupname username
# Or by GID
sudo usermod -g 1001 username
Group Management
Add to Groups
Add groups:
# Add to group (append)
sudo usermod -aG groupname username
# Add to multiple groups
sudo usermod -aG group1,group2 username
Set Groups
Replace groups:
# Set groups (replaces)
sudo usermod -G group1,group2 username
# Note: -G replaces, -aG appends
Troubleshooting
usermod Errors
Check user:
# Verify user exists
id username
# Check current groups
groups username
# Check home directory
ls -la /home/username
Summary
This guide covered usermod usage, user modification, and account management for Arch Linux, CachyOS, and other distributions.
Next Steps
- useradd Guide - User creation
- User and Groups - User management
- groupadd Guide - Group management
- usermod Documentation:
man usermod
This guide covers Arch Linux, CachyOS, and other Linux distributions. For distribution-specific details, refer to your distribution's documentation.