语法:

以下是如何使用GPasswd 命令的示例语法。

gpasswd [OPTION].  GROUP.

选项:

GROUP.要管理的帐户组的名称
-a, -add USER使用-a或者-add用户选项将a添加到组。将用户替换为我们希望添加到组的用户帐户
-d, -delete USER使用-d或者ddelete用户选项从组中删除用户。 。将用户替换为我们要删除的用户。
-R, -restrict使用-r或者-Restrict选项将AccrictAccess restrictAccess(或者-restrict)选项重新计算到其成员
-M, -members USER使用-m或者-members用户设置组成员列表
-A, -administrators ADMIN设置组的管理员列表..管理员名称或者用户帐户。

例子:

以下是如何在Ubuntu Linux上运行和使用GPasswd的一些示例。

将用户名John添加到players组:

gpasswd -a john players

赋予john管理员权限来管理players组:

gpasswd -A john players

如果我们未登为root帐户,则可能必须使用sudo命令。

sudo gpasswd -A john players

要从组中删除john的帐户,请运行以下命令。

sudo gpasswd -d john players

使用-help选项 查看gpasswd的帮助信息:

Usage: gpasswd [option] GROUP
Options:
  -a, --add USER                add USER to GROUP
  -d, --delete USER             remove USER from GROUP
  -h, --help                    display this help message and exit
  -Q, --root CHROOT_DIR         directory to chroot into
  -r, --remove-password         remove the GROUP's password
  -R, --restrict                restrict access to GROUP to its members
  -M, --members USER,.         set the list of members of GROUP
  -A, --administrators ADMIN,. 
                                set the list of administrators for GROUP
Except for the -A and -M options, the options cannot be combined.
如何在ubuntu上使用gpasswd命令

关于gpasswd命令:

gpasswd命令用于管理/etc/group和/etc/gshadow文件。

/etc/group文件包含组信息,/etc/gshadow文件包含加密组。

/etc/login.defs中的以下配置变量更改了GPasswd的行为。
编辑该文件以配置其他设置。

日期:2020-07-07 20:55:59 来源:oir作者:oir