工作中经常需要将用户加入docker组,可执行如下操作:
sudo gpasswd -a ec2-user docker
newgrp
# 不用加sudo
gpasswd
gpasswd -h
Usage: gpasswd [option] GROUP
Options:
-a, --add USER add USER to GROUP ## sudo gpasswd -a ec2-user docker,将 ec2-user 加入docker组
-d, --delete USER remove USER from GROUP
-h, --help display this help message and exit
-Q, --root CHROOT_DIR directory to chroot into
-r, --delete-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.
shadow-utils 工具集
# yum provides gpasswd
Loaded plugins: langpacks, priorities, update-motd
2:shadow-utils-4.1.5.1-24.amzn2.x86_64 : Utilities for managing accounts and shadow password files
Repo : amzn2-core
Matched from:
Filename : /usr/bin/gpasswd
其他命令
# rpm -ql shadow-utils-4.1.5.1-24.amzn2.0.2.x86_64 | grep -E "bin|lib"
/usr/bin/chage
/usr/bin/gpasswd
/usr/bin/lastlog
/usr/bin/newgrp
/usr/bin/sg
/usr/sbin/adduser
/usr/sbin/chpasswd
/usr/sbin/groupadd
/usr/sbin/groupdel
/usr/sbin/groupmems
/usr/sbin/groupmod
/usr/sbin/grpck
/usr/sbin/grpconv
/usr/sbin/grpunconv
/usr/sbin/newusers
/usr/sbin/pwck
/usr/sbin/pwconv
/usr/sbin/pwunconv
/usr/sbin/useradd
/usr/sbin/userdel
/usr/sbin/usermod
/usr/sbin/vigr
/usr/sbin/vipw
# 这些工具可以帮助系统管理员方便地管理用户和组,控制系统的访问权限和安全性。在许多 Linux 发行版中,shadow-utils 被默认安装在系统中,因为这些工具是管理 Linux 系统的重要组成部分。