refactor: moved to the right userland

This commit is contained in:
Michele Cereda
2023-12-31 11:27:54 +01:00
parent b8804a9722
commit 34edcfce9b
9 changed files with 147 additions and 109 deletions

View File

@@ -0,0 +1 @@
https://man.freebsd.org/cgi/man.cgi?pw(8)

View File

@@ -0,0 +1,3 @@
# Filesystem hierarchy standard
https://refspecs.linuxfoundation.org/fhs.shtml

View File

@@ -24,14 +24,11 @@ All the references in the [further readings] section, plus the following:
References
-->
<!-- Upstream -->
[software]: https://www.gnu.org/software/
<!-- In-article sections -->
[further readings]: #further-readings
<!-- Knowledge base -->
[parallel]: parallel.md
<!-- Upstream -->
[software]: https://www.gnu.org/software/
<!-- Others -->
[gnu userland]: https://www.linux.org/threads/gnu-userland.11066/

View File

@@ -0,0 +1,75 @@
# The `useradd` command
Creates new users.
1. [TL;DR](#tldr)
1. [Sources](#sources)
## TL;DR
```sh
# Create *regular* (non-system) users.
sudo useradd 'username'
sudo useradd -p 'encrypted password' 'username'
sudo useradd --password 'encrypted password' 'username'
# Create *system* users without an home directory.
sudo useradd -r 'username'
sudo useradd --system 'username'
# Specify the user ID.
sudo useradd -u '1005'
sudo useradd --uid '1002'
# Specify the primary group.
sudo useradd -g '100'
sudo useradd --gid 'users'
# Specify the expiration date.
sudo useradd -e '2022-10-10'
sudo useradd --expiredate '2022-04-13'
# Specify the login shell.
sudo useradd -s '/bin/bash'
sudo useradd --shell '/usr/bin/fish'
# Add the new users to *additional* groups.
sudo useradd -G 'audio'
sudo useradd --groups 'video,wheel'
# Force the creation of the new users' default home directory.
sudo useradd -m …
sudo useradd --create-home …
# Avoid the creation of the new users' default home directory.
sudo useradd -M …
sudo useradd --no-create-home …
# Force the creation of a group with the same name as the users.
sudo useradd -U …
sudo useradd --user-group …
# Avoid the creation of a group with the same name as the users.
sudo useradd -N …
sudo useradd --no-user-group …
# Create the users' home directory with specific template files.
sudo useradd -k 'path/to/template/directory' -m …
sudo useradd --skel 'path/to/template/directory' -m …
# Create a regular user with a home directory and the 'users' group as its
# primary group.
sudo useradd -mN -g 'users' -p '1234' 'user'
```
## Sources
- [cheat.sh]
<!--
References
-->
<!-- Others -->
[cheat.sh]: https://cheat.sh/useradd

View File

@@ -10,14 +10,16 @@ Delete users accounts and their related files.
## TL;DR
```sh
# Remove a user.
sudo userdel username
# Remove users.
sudo userdel 'username'
# Remove a user in other root directory.
sudo userdel --root path/to/other/root username
# Remove users from other (ch)root directories.
sudo userdel -R 'path/to/other/root' …
sudo userdel --root 'path/to/other/root' …
# Remove a user along with the home directory and mail spool.
sudo userdel --remove username
# Remove users along with their home directory and mail spool.
sudo userdel -r …
sudo userdel --remove …
```
## Sources

View File

@@ -0,0 +1,57 @@
# The `usermod` command
## Table of contents <!-- omit in toc -->
1. [TL;DR](#tldr)
1. [Sources](#sources)
## TL;DR
```sh
# Change users' primary group.
sudo usermod -g 'docker' 'bob'
sudo usermod --gid 'sudo' 'luke'
# Add/remove users to/from supplementary groups.
sudo usermod -aG 'wheel' 'carly'
sudo usermod --append --groups 'kvm,video,audio' 'alice'
sudo usermod -rG 'sudo,admin' 'eve'
sudo usermod --remove --groups 'proftpd' 'dina'
# Change users' login name.
sudo usermod -l 'to-stephen' 'from-michael'
sudo usermod --login 'to-floyd' 'from-rene'
# Change users' ID.
sudo usermod -u '1005' 'farra'
sudo usermod --uid '1001' 'hugo'
# Change users' login shell.
sudo usermod -s '/bin/zsh' 'rick'
sudo usermod --shell '/usr/bin/fish' 'morty'
# Change users' password.
sudo usermod -p 'encrypted password' 'john'
sudo usermod --password 'encrypted password' 'snow'
# Lock/unlock users.
sudo usermod -L 'damian'
sudo usermod --lock 'sergio'
sudo usermod -U 'ivan'
sudo usermod --unlock 'lez'
# Change users' home directory.
sudo usermod -md 'path/to/new/home' 'lenny'
sudo usermod --move-home --home 'path/to/new/home' 'lonny'
```
## Sources
- [cheat.sh]
<!--
References
-->
<!-- Others -->
[cheat.sh]: https://cheat.sh/usermod

View File

@@ -20,10 +20,10 @@ All the references in the [further readings] section, plus the following:
References
-->
<!-- Upstream -->
<!-- In-article sections -->
[further readings]: #further-readings
<!-- Knowledge base -->
<!-- Files -->
<!-- Upstream -->
<!-- Others -->

View File

@@ -1,49 +0,0 @@
# 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

View File

@@ -1,48 +0,0 @@
# The `usermod` command
## Table of contents <!-- omit in toc -->
1. [TL;DR](#tldr)
1. [Sources](#sources)
## TL;DR
```sh
# 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]
<!--
References
-->
<!-- Others -->
[cheat.sh]: https://cheat.sh/usermod