useradd
Create a new user or update default new user information.
Basic Usage
Create a standard user with a home directory.
useradd -m [username]
Create a user with a specific full name (comment).
useradd -c "[comment]" [username]
Set the password for the new user immediately.
passwd [username]
Advanced & Professional Scenarios
System Users
Create a system user (no home directory, no login shell). Useful for running services.
useradd -r -s /bin/false [username]
Create a system user with a specific home directory for application data.
useradd -r -m -d /opt/myapp -s /bin/bash [username]
Group Management
Create a user with a specific primary group.
useradd -g [group] [username]
Create a user and add them to multiple secondary groups.
useradd -G [groups] [username]
Create a user with a custom User ID (UID).
useradd -u 1500 [username]
Security & Expiry
Create a user with an account expiry date.
useradd -e [expiry_date] [username]
Create a user whose password expires after a specific number of days.
useradd -f 30 [username]
Custom Home & Shell
Create a user with a non-standard home directory location.
useradd -m -d /data/users/[username] [username]
Create a user with a specific shell (e.g., Zsh).
useradd -s /usr/bin/zsh [username]
Skeleton Directory
Use a custom skeleton directory (template files like .bashrc) when creating the home directory.
useradd -m -k /etc/skel_custom [username]
Default Configuration
View default values for new users.
useradd -D
Change the default shell for future users.
useradd -D -s /bin/zsh