usermod -a -G参数a加与不加的区别

系统安装、升级讨论
版面规则
我们都知道新人的确很菜,也喜欢抱怨,并且带有浓厚的Windows习惯,但既然在这里询问,我们就应该有责任帮助他们解决问题,而不是直接泼冷水、简单的否定或发表对解决问题没有任何帮助的帖子。乐于分享,以人为本,这正是Ubuntu的精神所在。
回复
云海幻梦
帖子: 51
注册时间: 2023-02-21 9:52
系统: linux

usermod -a -G参数a加与不加的区别

#1

帖子 云海幻梦 » 2023-03-04 20:38

usermod -a -G参数a加与不加的区别,查看man手册,usermod -G与usermod -a -G效果应该是不一样,建了3个用户组做测试我执行了一下怎么都是一样添加的效果?!
-a, --append
Add the user to the supplementary group(s). Use only with the -G
option.
-G, --groups GROUP1[,GROUP2,...[,GROUPN]]]
A list of supplementary groups which the user is also a member of.
Each group is separated from the next by a comma, with no
intervening whitespace. The groups are subject to the same
restrictions as the group given with the -g option.

If the user is currently a member of a group which is not listed,
the user will be removed from the group. This behaviour can be
changed via the -a option, which appends the user to the current
supplementary group list.
onlylove
论坛版主
帖子: 5371
注册时间: 2007-01-14 16:23

Re: usermod -a -G参数a加与不加的区别

#2

帖子 onlylove » 2023-03-04 21:14

If the user is currently a member of a group which is not listed,
the user will be removed from the group.
This behaviour can be
changed via the -a option, which appends the user to the current
supplementary group list.


你只看了添加,没看移除?
云海幻梦
帖子: 51
注册时间: 2023-02-21 9:52
系统: linux

Re: usermod -a -G参数a加与不加的区别

#3

帖子 云海幻梦 » 2023-03-04 21:28

英文看得云里雾里,单对移除方面来讲,我理解为加了-a后的原user不移除?不加-a后原user移除?!
云海幻梦
帖子: 51
注册时间: 2023-02-21 9:52
系统: linux

Re: usermod -a -G参数a加与不加的区别

#4

帖子 云海幻梦 » 2023-03-04 21:49

从字面上翻译:(命令中)没有被列出的user
将被从原组中移除?
头像
astolia
论坛版主
帖子: 6703
注册时间: 2008-09-18 13:11

Re: usermod -a -G参数a加与不加的区别

#5

帖子 astolia » 2023-03-04 22:13

一个是设置用户只属于指定的组,一个是将用户添加到指定的组
云海幻梦
帖子: 51
注册时间: 2023-02-21 9:52
系统: linux

Re: usermod -a -G参数a加与不加的区别

#6

帖子 云海幻梦 » 2023-03-04 22:37

👌🌹
云海幻梦
帖子: 51
注册时间: 2023-02-21 9:52
系统: linux

Re: usermod -a -G参数a加与不加的区别

#7

帖子 云海幻梦 » 2023-03-04 23:23

以下这个翻译貌似还可以,但也生硬:
-a将用户添加到新组时,请始终使用(append) 选项。如果省略该-a选项,则用户将从-G选项后未列出的组中删除。
回复