usermod
-a|--append ##把用户追加到某些组中,仅与-G选项一起使用
-c|--comment ##修改/etc/passwd文件第五段comment
-d|--home ##修改用户的家目录通常和-m选项一起使用
-e|--expiredate ##指定用户帐号禁用的日期,格式YY-MM-DD
-f|--inactive ##用户密码过期多少天后采用就禁用该帐号,0表示密码已过期就禁用帐号,-1表示禁用此功能,默认值是-1
-g|--gid ##修改用户的gid,改组一定存在
-G|--groups ##把用户追加到某些组中,仅与-a选项一起使用
-l|--login ##修改用户的登录名称
-L|--lock ##锁定用户的密码
-m|--move-home ##修改用户的家目录通常和-d选项一起使用
-s|--shell ##修改用户的shell
-u|--uid ##修改用户的uid,该uid必须唯一
-U|--unlock ##解锁用户的密码

1、新建用户test,密码test,另外添加usertest组
useradd test
echo "test" | passwd --stdin test
groupadd usertest

2、把test用户加入usertest组
usermod -aG usertest test ##多个组之间用空格隔开

3、修改test用户的家目录
usermod -md /home/usertest

4、修改用户名
usermod -l testnew(新用户名称) test(原来用户名称)

5、锁定用户
usermod -L testnew

6、解锁testnew的密码
usermod -U testnew

7、修改用户的shell
usermod -s /bin/sh testnew

8、修改用户的UID
usermod -u 578 testnew (UID必须唯一)

9、修改用户的GID
groupadd -g 578 test1
usermod -g 578 testnew (578组一定要存在)

10、指定帐号过期日期
usermod -e 2012-09-11 testnew

11、指定用户帐号密码过期多少天后,禁用该帐号
usermod -f 0 testnew

posted on 2018-06-17 11:03  新美好时代  阅读(351)  评论(0编辑  收藏  举报