新建用户:libai(李白),dufu(杜甫),baijuyi(白居易)
新建组:tangdinasty(唐朝)。
useradd libai
useradd dufu
useradd baijuyi
groupadd tangdinasty
方式一,从用户角度添加到组:
#-a, --append append the user to the supplemental GROUPS
# mentioned by the -G option without removing
# the user from other groups
#-G, --groups GROUPS new list of supplementary GROUPS
usermod -aG tangdinasty libai
方式二,胸组的角度添加到组:
#-a, --add USER add USER to GROUP
gpasswd -a dufu tangdinasty
gpasswd -a dufu baijuyi
最终: