usermod -a表示在原來所屬組的基礎上追加
groupadd group1
groupadd group2
useradd user1
usermod -G group1 user1
id user1
uid=1006(user1) gid=1014(user1) 組=1014(user1),1013(group1)
usermod -G group2 user1
id user1
uid=1006(user1) gid=1014(user1) 組=1014(user1),1010(group2)
useradd user2
usermod -G group1 user2
id user2
uid=1007(user2) gid=1015(user2) 組=1015(user2),1013(group1)
usermod -a -G group2 user2
id user2
uid=1007(user2) gid=1015(user2) 組=1015(user2),1010(group2),1013(group1)