我有几个用户说:A,B,C,D等2组:主,从。 每个用户只属于这些组中的一个(排他性)。 如何以编程方式更改此所有权?
例如:用户A属于“master”组 如何从“master”组中删除它并将其添加到“slave”组?
答案 0 :(得分:1)
来自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.
如果由于某种原因未在您的系统上预安装,则该命令来自pwdutils
包。