HiveBrain v1.2.0
Get Started
← Back to all entries
snippetbashTip

useradd — Create a new user. See also: `users`, `userdel`, `usermod`. More information: <https://manned.org/us

Submitted by: @import:tldr-pages··
0
Viewed 0 times
createcommandnewuseraddcliuserseealso
linux

Problem

How to use the useradd command: Create a new user. See also: users, userdel, usermod. More information: <https://manned.org/useradd>.

Solution

useradd — Create a new user. See also: users, userdel, usermod. More information: <https://manned.org/useradd>.

Create a new user:
sudo useradd {{username}}


Create a new user with the specified user ID:
sudo useradd {{[-u|--uid]}} {{id}} {{username}}


Create a new user with the specified shell:
sudo useradd {{[-s|--shell]}} {{path/to/shell}} {{username}}


Create a new user belonging to additional groups (mind the lack of whitespace):
sudo useradd {{[-G|--groups]}} {{group1,group2,...}} {{username}}


Create a new user with the default home directory:
sudo useradd {{[-m|--create-home]}} {{username}}


Create a new user with the home directory filled by template directory files:
sudo useradd {{[-k|--skel]}} {{path/to/template_directory}} {{[-m|--create-home]}} {{username}}


Create a new system user without the home directory:
sudo useradd {{[-r|--system]}} {{username}}

Code Snippets

Create a new user

sudo useradd {{username}}

Create a new user with the specified user ID

sudo useradd {{[-u|--uid]}} {{id}} {{username}}

Create a new user with the specified shell

sudo useradd {{[-s|--shell]}} {{path/to/shell}} {{username}}

Create a new user belonging to additional groups (mind the lack of whitespace)

sudo useradd {{[-G|--groups]}} {{group1,group2,...}} {{username}}

Create a new user with the default home directory

sudo useradd {{[-m|--create-home]}} {{username}}

Context

tldr-pages: linux/useradd

Revisions (0)

No revisions yet.