Added user management-related notes to the knowledge base

This commit is contained in:
Michele Cereda
2022-05-14 09:29:35 +02:00
parent b66223b421
commit 6e4b50adc3
3 changed files with 93 additions and 2 deletions

39
knowledge base/useradd.md Normal file
View File

@@ -0,0 +1,39 @@
# Useradd
Create a new user.
## TL;DR
```shell
# 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]
[cheat.sh]: cheat.sh/useradd

22
knowledge base/userdel.md Normal file
View File

@@ -0,0 +1,22 @@
# Useradd
Delete a user account and its related files.
## TL;DR
```shell
# Remove a user.
sudo userdel username
# Remove a user in other root directory.
sudo userdel --root path/to/other/root username
# Remove a user along with the home directory and mail spool.
sudo userdel --remove username
```
## Sources
- [cheat.sh]
[cheat.sh]: cheat.sh/userdel

View File

@@ -3,6 +3,36 @@
## TL;DR
```shell
# Add users to a group.
sudo usermod --append --groups boinc user
# Change a user's primary group.
sudo usermod -g docker bob
# Add/remove a user to/from supplementary groups.
sudo usermod -aG wheel carly
sudo usermod --append --groups kvm,video,audio alice
sudo usermod -rG sudo,admin eve
# Change a user's login name
sudo usermod --login to-stephen from-micha
# Change a user's ID.
sudo usermod --uid 1001 hugo
# Change a user's shell.
sudo usermod --shell /usr/bin/zsh rick
# Change a user's password.
sudo usermod -p encryptedPassword john
# Lock/unlock a user.
sudo usermod -L damian
sudo usermod -U luke
# Change a user's home directory.
sudo usermod --move-home --home path/to/new_home lonny
```
## Sources
- [cheat.sh]
[cheat.sh]: cheat.sh/usermod