From 9be573bc4effa615c5448c609aaf8da6ddb092a7 Mon Sep 17 00:00:00 2001 From: litianci Date: Sat, 3 Sep 2022 21:21:51 +0800 Subject: [PATCH 1/2] Added more detailed descriptions and examples --- docs/books/admin_guide/06-users.md | 44 ++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 3 deletions(-) diff --git a/docs/books/admin_guide/06-users.md b/docs/books/admin_guide/06-users.md index 14bf98854b..9beca05fdc 100644 --- a/docs/books/admin_guide/06-users.md +++ b/docs/books/admin_guide/06-users.md @@ -145,13 +145,51 @@ $ sudo groupdel GroupC !!! Tip - To be deleted, a group must no longer contain users. + There are two situations: when a user has a unique primary group, if you use the `groupdel` command, you will be prompted that there is a specific user under the group and cannot be deleted; if it exists in the form of an supplementary groups, there will be no prompt after deleting the group. -Deleting the last user of an eponymous group will cause the system to delete the group. +```bash +Shell > useradd testa +Shell > id testa +uid=1000(testa) gid=1000(testa) 组=1000(testa) +Shell > groupdel testa +groupdel: cannot remove the primary group of user 'testa' + +Shell > groupadd -g 1001 testb +Shell > usermod -G testb root +Shell > id root +uid=0(root) gid=0(root) 组=0(root),1001(testb) +Shell > groupdel testb +``` + +!!! Tip + + When you delete a user using the `userdel -r` command, the corresponding primary group is also deleted. The primary group name is usually the same as the user name. !!! Tip - Each group has a unique `GID`. A group can be duplicated. By convention, the `GID` of system groups range from 0 (`root`) to 999. + Each group has a unique `GID`. A group can be used by multiple users as an supplementary groups. By convention, The GID of super administrator is 0; The GIDS reserved for some services or processes are 201~999, which are called system groups or pseudo user groups; The GID for users is usually greater than or equal to 1000. These are related to /etc/login.defs, which we will talk about later. + +```bash +shell > egrep -v "^#|^$" /etc/login.defs +MAIL_DIR /var/spool/mail +UMASK 022 +HOME_MODE 0700 +PASS_MAX_DAYS 99999 +PASS_MIN_DAYS 0 +PASS_MIN_LEN 5 +PASS_WARN_AGE 7 +UID_MIN 1000 +UID_MAX 60000 +SYS_UID_MIN 201 +SYS_UID_MAX 999 +GID_MIN 1000 +GID_MAX 60000 +SYS_GID_MIN 201 +SYS_GID_MAX 999 +CREATE_HOME yes +USERGROUPS_ENAB yes +ENCRYPT_METHOD SHA512 +``` !!! Tip From 46a2a2636705c7f5ed2e4537c87f7c6048227cf3 Mon Sep 17 00:00:00 2001 From: sspencerwire Date: Sat, 3 Sep 2022 10:42:19 -0500 Subject: [PATCH 2/2] Clarified the English/Grammar * Clarified the English used for the additional tip items * Examples are part of the admonition text, so these have been moved within the context of the admonition --- docs/books/admin_guide/06-users.md | 81 ++++++++++++++++-------------- 1 file changed, 43 insertions(+), 38 deletions(-) diff --git a/docs/books/admin_guide/06-users.md b/docs/books/admin_guide/06-users.md index 9beca05fdc..ac09e11cc1 100644 --- a/docs/books/admin_guide/06-users.md +++ b/docs/books/admin_guide/06-users.md @@ -145,21 +145,26 @@ $ sudo groupdel GroupC !!! Tip - There are two situations: when a user has a unique primary group, if you use the `groupdel` command, you will be prompted that there is a specific user under the group and cannot be deleted; if it exists in the form of an supplementary groups, there will be no prompt after deleting the group. - -```bash -Shell > useradd testa -Shell > id testa -uid=1000(testa) gid=1000(testa) 组=1000(testa) -Shell > groupdel testa -groupdel: cannot remove the primary group of user 'testa' - -Shell > groupadd -g 1001 testb -Shell > usermod -G testb root -Shell > id root -uid=0(root) gid=0(root) 组=0(root),1001(testb) -Shell > groupdel testb -``` + When deleting a group, there are two conditions that can occur: + + * If a user has a unique primary group and you issue the `groupdel` command on that group, you will be prompted that there is a specific user under the group and it cannot be deleted. + * If a user belongs to a suplementary group (not the primary group for the user) and that group is not the primary group for antoher user on the system, then the `groupdel` command will delete the group without any additional prompts. + + Examples: + + ```bash + Shell > useradd testa + Shell > id testa + uid=1000(testa) gid=1000(testa) group=1000(testa) + Shell > groupdel testa + groupdel: cannot remove the primary group of user 'testa' + + Shell > groupadd -g 1001 testb + Shell > usermod -G testb root + Shell > id root + uid=0(root) gid=0(root) group=0(root),1001(testb) + Shell > groupdel testb + ``` !!! Tip @@ -167,29 +172,29 @@ Shell > groupdel testb !!! Tip - Each group has a unique `GID`. A group can be used by multiple users as an supplementary groups. By convention, The GID of super administrator is 0; The GIDS reserved for some services or processes are 201~999, which are called system groups or pseudo user groups; The GID for users is usually greater than or equal to 1000. These are related to /etc/login.defs, which we will talk about later. - -```bash -shell > egrep -v "^#|^$" /etc/login.defs -MAIL_DIR /var/spool/mail -UMASK 022 -HOME_MODE 0700 -PASS_MAX_DAYS 99999 -PASS_MIN_DAYS 0 -PASS_MIN_LEN 5 -PASS_WARN_AGE 7 -UID_MIN 1000 -UID_MAX 60000 -SYS_UID_MIN 201 -SYS_UID_MAX 999 -GID_MIN 1000 -GID_MAX 60000 -SYS_GID_MIN 201 -SYS_GID_MAX 999 -CREATE_HOME yes -USERGROUPS_ENAB yes -ENCRYPT_METHOD SHA512 -``` + Each group has a unique `GID`. A group can be used by multiple users as a supplementary group. By convention, The GID of super administrator is 0. The GIDS reserved for some services or processes are 201~999, which are called system groups or pseudo user groups. The GID for users is usually greater than or equal to 1000. These are related to /etc/login.defs, which we will talk about later. + + ```bash + shell > egrep -v "^#|^$" /etc/login.defs + MAIL_DIR /var/spool/mail + UMASK 022 + HOME_MODE 0700 + PASS_MAX_DAYS 99999 + PASS_MIN_DAYS 0 + PASS_MIN_LEN 5 + PASS_WARN_AGE 7 + UID_MIN 1000 + UID_MAX 60000 + SYS_UID_MIN 201 + SYS_UID_MAX 999 + GID_MIN 1000 + GID_MAX 60000 + SYS_GID_MIN 201 + SYS_GID_MAX 999 + CREATE_HOME yes + USERGROUPS_ENAB yes + ENCRYPT_METHOD SHA512 + ``` !!! Tip