LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1352|回复: 10

向大哥们请教一个关于usermod的问题,谢谢!

[复制链接]
发表于 2005-8-10 20:08:35 | 显示全部楼层 |阅读模式
请问:用usermod 能否将用户a加入到群组b,并且用户a同时属于群组a和群组b?以下三种方法行否?
1、是用usermod -g?
2、还是usermod -G?
3、还是直接把用户a写到/etc/group中群组b的那一行中?
回答时请您分别详细(感谢)说出以上三种方法行否,达到的效果是什么?
万分感谢!!!
发表于 2005-8-11 14:50:01 | 显示全部楼层
usermod 的2个参数
[-g initial_group] [-G group [,...]]

       -g initial_group
              The group name or number of the user's new initial login  group.
              The  group  name  must  exist.   A group number must refer to an
              already existing group.  The default group number is 1.

       -G group,[...]
              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



其实直接修改passwd即可加入相应组的
列:
test:x:521:50::/ftpuser/test:/sbin/nologin
521为TEST的UID 50为FTP组的GID
回复 支持 反对

使用道具 举报

发表于 2005-8-11 18:00:39 | 显示全部楼层
一个用户可以没有标准组(usermod -G),但是必须要有私有组(usermod -g),并且只能有一个.具体是哪一个,你得看a和b组的身份,如果都是标准组,你可以去更改/etc/group文件了.在GID后面加上用户名.
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-8-11 19:54:52 | 显示全部楼层
Post by konds
usermod 的2个参数
[-g initial_group] [-G group [,...]]

       -g initial_group
              The group name or number of the user's new initial login  group.
              The  group  name  must  exist.   A group number must refer to an
              already existing group.  The default group number is 1.

       -G group,[...]
              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



其实直接修改passwd即可加入相应组的
列:
test:x:521:50::/ftpuser/test:/sbin/nologin
521为TEST的UID 50为FTP组的GID

大哥!!请将中文啦!!谢谢啊!!
请问test现在是不是仅FTP这一个组的成员,而不是其他任何组的成员??谢谢
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-8-11 20:03:01 | 显示全部楼层
Post by lvhui_cn
一个用户可以没有标准组(usermod -G),但是必须要有私有组(usermod -g),并且只能有一个.具体是哪一个,你得看a和b组的身份,如果都是标准组,你可以去更改/etc/group文件了.在GID后面加上用户名.

请问:
1、请问什么是标准组和私有组最主要区别是什么?
2、文件a.txt的所有者是用户a,a.txt的权限是740,用户a属于群组a。文件b.txt的所有者是用户b,b.txt的权限是740,用户b属于群组b。如果root用usermod -G b a,能使用户b能够读a.txt这个文件,并同时不再能读b.txt吗?
回复 支持 反对

使用道具 举报

发表于 2005-8-12 06:02:52 | 显示全部楼层
Post by yaoyuan11
请问:
1、请问什么是标准组和私有组最主要区别是什么?
2、文件a.txt的所有者是用户a,a.txt的权限是700,用户a属于群组a。文件b.txt的所有者是用户b,b.txt的权限是700,用户b属于群组b。如果root用usermod -G b a,能使用户b能够读a.txt这个文件,并同时不再能读b.txt吗?


1. 我不知道这个私有组和标准组的中文翻译是否合适,我理解的一个是用户的基本登录组,一个是附属的组。更改附属组属性不会牵涉到用户的基本组。用户创建的文件,目录都与这个组相关,不于其他任何的附属组相关。
2. 既然是700属性,更改组属性不会起任何作用。因为文件只有创建用户和root可读。
回复 支持 反对

使用道具 举报

发表于 2005-8-12 09:35:43 | 显示全部楼层
我的翻译是-g 指定的是默认组,也就是/etc/passwd中定义的gid,当user login进入系统后,id 看到的gid= 就是这个值,也就是用户默认所属组,用户建立文件和目录时其group owner 就是这个gid。
-G我翻译为候选组, 也就是/etc/group 和/etc/gshadow里那些组名“:”后保护此user name ,当user login进入系统后,id 看到的groups=用“,”分割的值,也就是用户同时是这些组的成员,如果希望在当前shell中改变gid=的默认组可以使用newgrp gid 来修改,这样做之后用户建立文件和目录时其group owner 就是这个新的gid了。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-8-12 11:08:54 | 显示全部楼层
Post by yongjian
1. 我不知道这个私有组和标准组的中文翻译是否合适,我理解的一个是用户的基本登录组,一个是附属的组。更改附属组属性不会牵涉到用户的基本组。用户创建的文件,目录都与这个组相关,不于其他任何的附属组相关。
2. 既然是700属性,更改组属性不会起任何作用。因为文件只有创建用户和root可读。

sorry,不应该是700,是740,请问这样的后果呢,谢谢!
回复 支持 反对

使用道具 举报

发表于 2005-8-12 12:32:08 | 显示全部楼层
Post by yaoyuan11
sorry,不应该是700,是740,请问这样的后果呢,谢谢!

还是不太清楚。
  1. usermode -G b a
复制代码
将a加入b组,这和b能不能读a的文件好像没有什么关系。如果反过来想,
  1. usermod -G a b
复制代码
的话,b也不会丢失对自己创建的文件的可读权啊。
回复 支持 反对

使用道具 举报

发表于 2005-8-13 22:43:05 | 显示全部楼层
1,2没试过
3最直接
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表