Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1450553
  • 博文数量: 263
  • 博客积分: 10851
  • 博客等级: 上将
  • 技术积分: 2627
  • 用 户 组: 普通用户
  • 注册时间: 2008-11-26 22:40
文章分类

全部博文(263)

文章存档

2013年(4)

2012年(25)

2011年(33)

2010年(50)

2009年(138)

2008年(13)

分类: LINUX

2008-12-17 23:11:36

useradd的几个选项
-M 表示不建立用户家目录,默认建立的家目录为/home/new_user_name
在redhat系列的distribution中新建用户的默认组名为自己,而在suse10中新建用户的默认组为user
所以在suse10中新建用户时, 还应指定其所属用户组,使用usermod
usermod的几个选项
-g 表示指定用户的初始登录组,在/etc/passwd中该用户的组id
-G  表示把该用户加入到某组, 但是并不是用户的初始组, 可以看/etc/groups验证
 
或者在useradd之前执行groupadd新增一个用户组, 然后在useradd的时候使用-g选项指定其所属用户组
比如:
groupadd mysql
useradd -g mysql mysql
 
-d HOME_DIR  指定家目录。 默认情况下, 如果在/etc/login.def中定义的CREATE_HOME = yes的话, 会自动建立家目录, 不过家目录的默认目录是 BASE_DIR + 用户名
# useradd -m -d /usr/local/app -k /etc/skel xyz
 
 
# 如何建立用户别名(亦即用户A跟用户B具有完全相同的属性, 除了用户名和密码)
1. 关掉nscd服务
2. 新: useradd -o -M -d /home/iverson -s /bin/bash -u 502 -g iverson cp_iverson
    a. cp_iverson 起的服务能被 iverson kill掉, 反之亦然(因为kill只判断uid)
    b. cp_iverson 跟 iverson 同一份crontab(/var/spool/cron/iverson, 不同的发行版, 可能该文件的位置不一样)
    c. cp_iverson 可以 strace iverson的进程, 反之亦然
    d. 登录时, 使用iverson/cp_iverson各自的密码, 登录后显示iverson用户名(如果PS1有设置显示用户名的话)
    e. 单独使用passwd命令时, 修改的始终是iverson的密码, 因为iverson密码只有我们知道, 而cp_iverson的密码是动态维护,所以没关系
   旧: useradd -o -M -d /home/tmac -s /bin/bash -u 503 -G tmac cp_tmac
    a. cp_iverson 起的服务能被 iverson kill掉, 反之亦然(因为kill只判断uid)
    b. cp_iverson 跟 iverson 同一份crontab(/var/spool/cron/iverson, 不同的发行版, 可能该文件的位置不一样)
    c. cp_iverson 不可以 strace iverson的进程, 同样iverson 也不能strace cp_iverson的进程(strace要同时判断进程uid和gid)
    d. 登录时, 使用iverson/cp_iverson各自的密码, 登录后显示iverson用户名(如果PS1有设置显示用户名的话)
    e. 单独使用passwd命令时, 修改的始终是iverson的密码, 因为iverson密码只有我们知道, 而cp_iverson的密码是动态维护, 所以没关系

-g / -G的区别:
    -g, --gid GROUP
           The group name or number of the user′s initial login group. The group name must exist. A group number must refer to an already existing group.
    -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. The default is for the user to belong only to the initial group.
    -o, --non-unique
           Allow the creation of a user account with a duplicate (non-unique) UID.
           This option is only valid in combination with the -o option.
 
 
阅读(975) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~