[root@localhost /]# id hanfeng 這個組不只包括了前面的gid,還能夠包括其餘的擴展組 uid=1000(hanfeng) gid=1000(hanfeng) 組=1000(hanfeng) [root@localhost /]# groupadd ha1 [root@localhost /]# usermod -G ha1 hanfeng [root@localhost /]# id hanfeng uid=1000(hanfeng) gid=1000(hanfeng) 組=1000(hanfeng),1001(ha1) [root@localhost /]# useradd user3 [root@localhost /]# usermod -G user3 hanfeng [root@localhost /]# id hanfeng 這裏會發現指定-G以後,user3組替代了ha1組 uid=1000(hanfeng) gid=1000(hanfeng) 組=1000(hanfeng),1002(user3) [root@localhost /]# usermod -G ha1,user3 hanfeng 同時添加多個組 [root@localhost /]# id hanfeng uid=1000(hanfeng) gid=1000(hanfeng) 組=1000(hanfeng),1001(ha1),1002(user3)
一個用戶,它能夠屬於多個組,可是這個gid只有一個,咱們就能夠把除了gid以外的組,稱之爲擴展組
[root@localhost /]# usermod -g ha1,user3 hanfeng usermod:「ha1,user3」組不存在 [root@localhost /]# usermod -g ha1 hanfeng [root@localhost /]# !id id hanfeng uid=1000(hanfeng) gid=1001(ha1) 組=1001(ha1),1002(user3)
--g與-G的區別,-g只能只能指定一個組,而-G能夠指定多個組shell