Files
oam/knowledge base/useradd.md
2023-12-24 19:35:27 +01:00

50 lines
1.1 KiB
Markdown

# The `useradd` command
Creates new users.
## Table of contents <!-- omit in toc -->
1. [TL;DR](#tldr)
1. [Sources](#sources)
## TL;DR
```sh
# Create a new user.
sudo useradd username
sudo useradd -p encryptedPassword username
# Create a new user with the specified user ID.
sudo useradd --uid id username
# Create a new user with the specified expiration date.
sudo useradd -e 2022-10-10 username
# Create a new user with the specified shell.
sudo useradd --shell path/to/shell username
# Create a new user belonging to additional groups.
sudo useradd --groups group1,group2,... username
# Create a new user with or without its default home directory.
sudo useradd --create-home username
sudo useradd --no-create-home username
# Create a new user with the home directory filled by template directory files.
sudo useradd --skel path/to/template_directory --create-home username
# Create a new system user without the home directory.
sudo useradd --system username
```
## Sources
- [cheat.sh]
<!--
References
-->
<!-- Others -->
[cheat.sh]: https://cheat.sh/useradd