开发者

How to change user affilations to group in Linux

I have several users say: A,B,C,D, etc. and 2 group: master, slave. Each user belongs to only one of these groups (exclusively). How can I programmatically change this belonging?

For example: user A belongs to group "mast开发者_开发问答er" How to remove it from group "master" and add it to group "slave"?


From the man page of usermod:

-G, --groups group,...
With this option a list of supplementary groups can be specified, which the user should become a member of. Each group is separated from the next one only by a comma, without whitespace. The user is removed from all other groups not specified.


-R, --remove-from-group group,...
With this option a list of groups can be specified, from which the user should be removed. Each group is separated from the next one only by a comma, without whitespace.

If for some reason this isn't pre-installed on your system it is a command from the pwdutils package.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜