usermod 命令使用说明

功能说明:修改用户帐号。

语  法:usermod [-LU][-c <备注>][-d <登入目录>][-e <有效期限>][-f <缓冲天数>][-g <群组>][-G <群组>][-l <帐号名称>][-s <shell>][-u <uid>][用户帐号]

补充说明:usermod可用来修改用户帐号的各项设定。

参  数:

 -c<备注>  修改用户帐号的备注文字。
 -d登入目录>  修改用户登入时的目录。
 -e<有效期限>  修改帐号的有效期限。
 -f<缓冲天数>  修改在密码过期后多少天即关闭该帐号。
 -g<群组>  修改用户所属的群组。
 -G<群组>  修改用户所属的附加群组。
 -l<帐号名称>  修改用户帐号名称。
 -L  锁定用户密码,使密码无效。
 -s<shell>  修改用户登入后所使用的shell。
 -u<uid>  修改用户ID。
 -U  解除密码锁定。

    -a, --append          append the user to the supplemental GROUPS 
                                mentioned by the -G option without removing 
                                him/her from other groups 
usermod 不 允 许 你 改 变 正 在线 上 的 使 用 者 帐 号 名 称 。 当 usermod 用 来 改 变 user ID, 必 须 确 认 这 名 user 没 在 电 脑 上 执 行 任 何 程 序。 你 需 手 动 更 改 使 用 者 的 crontab 档 。 也 需 手 动 更 改 使 用 者 的 at 工 作 档 。 采 用 NIS server 须 在 server 上 更 动 相 关 的 NIS 设 定 。

应用举例:

1、将 newuser2 添加到组 staff 中
# usermod -G staff newuser2


2、修改 newuser 的用户名为 newuser1
# usermod -l newuser1 newuser


3、锁定账号 newuser1
# usermod -L newuser1


4、解除对 newuser1 的锁定
# usermod -U newuser1

 

5、将一个用户添加到用户组中,千万不能直接用: 

usermod -G groupA 

这样做会使你离开其他用户组,仅仅做为 这个用户组 groupA 的成员。 

应该用 加上 -a 选项: 

usermod -a -G groupA user

(FC4: usermod -G groupA,groupB,groupC user)

-a 代表 append, 也就是 将自己添加到 用户组groupA 中,而不必离开 其他用户组。 

 

[lm@eccs_web font]$ groups lm

lm : lm root

备注:用户lm属于lm 和 root组。

或者查看文件:$ cat /etc/group

猜你喜欢

转载自hbiao68.iteye.com/blog/2154656