Which language do you prefer? English 简体中文 繁体中文
...

Part of Linux Commands Cheat Sheet

Add a user:


useradd username

The default home directory is /home/username, default login shell is /bin/sh.

Options:


useradd -m username # create home directory if not exists
useradd -d /data username # specify home directory
useradd -M username # without home directory
useradd -u 999 username # specify user ID
useradd -g 500 username # specify group ID
useradd -G admins,webadmin username # specify groups
useradd -s /bin/bash username # specify login shell
useradd -c "Example" username # custom comments

Example:


useradd -s /bin/bash -m wujunchao

After created, a new line will appear in /etc/passwd file:


wbswjc:1001:1001::/home/wujunchao:/bin/bash

References

Linux User Management

The Complete Guide to “useradd” Command in Linux – 15 Practical Examples

wbswjc-blog