User Account Creation
User Account Management Methods
Linux provides multiple approaches to create user accounts, with two primary commands: useradd
and adduser
. Each method offers different levels of configuration and interaction.
graph LR
A[User Account Creation] --> B[useradd Command]
A --> C[adduser Command]
B --> D[Manual Configuration]
C --> E[Interactive Configuration]
Using useradd Command
The useradd
command offers precise, script-friendly user account creation:
## Create a new user
sudo useradd johndoe
## Create user with specific home directory
sudo useradd -m -d /home/johndoe johndoe
## Create user with specific shell
sudo useradd -s /bin/bash johndoe
User Account Configuration Options
Option |
Description |
Example |
-m |
Create home directory |
useradd -m username |
-s |
Specify login shell |
useradd -s /bin/bash username |
-g |
Assign primary group |
useradd -g developers username |
-G |
Assign supplementary groups |
useradd -G sudo,admin username |
Setting User Password
After creating a user account, set the initial password:
## Set password for new user
sudo passwd johndoe
This command initiates an interactive password configuration process, ensuring secure initial access to the new user account.