2015年(48)
分类: LINUX
2015-08-17 01:08:25
- 参考资料:usermod manpage
- -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 ##解锁用户的密码
- #useradd test
- #echo "test" | passwd --stdin test
- #groupadd usertest
- #usermod -aG usertest test ##多个组之间用空格隔开
- #id test
- uid=500(test) gid=500(test) groups=500(test),501(usertest)
- #usermod -md /home/usertest
- #ls /home
- usertest
- #usermod -l urchin(新用户名称) test(原来用户名称)
- #id urchin
- uid=500(urchin) gid=500(test) groups=500(test),501(usertest)
- # sed -n '$p' /etc/shadow
- urchin:$6$1PwPVBn5$o.MIEYONzURQPvn/YqSp69kt2CIASvXhOnjv/t \
- Z5m4NN6bJyLjCG7S6vmji/PFDfbyITdm1WmtV45CfHV5vux/:15594:0:99999:7:::
- #usermod -L urchin
- # sed -n '$p' /etc/shadow
- urchin:!$6$1PwPVBn5$o.MIEYONzURQPvn/YqSp69kt2CIASvXhOnjv/t \
- Z5m4NN6bJyLjCG7S6vmji/PFDfbyITdm1WmtV45CfHV5vux/:15594:0:99999:7:::
- #usermod -U urchin
- # sed -n '$p' /etc/shadow
- urchin:$6$1PwPVBn5$o.MIEYONzURQPvn/YqSp69kt2CIASvXhOnjv/t \
- Z5m4NN6bJyLjCG7S6vmji/PFDfbyITdm1WmtV45CfHV5vux/:15594:0:99999:7:::
- #sed '$!d' /etc/passwd
- urchin:x:500:500::/home/usertest:/bin/bash
- #usermod -s /bin/sh urchin
- #sed -n '$p' /etc/passwd
- urchin:x:500:500::/home/usertest:/bin/sh
- #usermod -u 578 urchin (UID必须唯一)
- #id urchin
- uid=578(urchin) gid=500(test) groups=500(test),501(usertest)
- #groupadd -g 578 test1
- #usermod -g 578 urchin (578组一定要存在)
- #id urchin
- uid=578(urchin) gid=578(test1) groups=578(test1),501(usertest)
- # sed -n '$p' /etc/shadow
- urchin:$6$1PwPVBn5$o.MIEYONzURQPvn/YqSp69kt2CIASvXhOnjv/t \
- Z5m4NN6bJyLjCG7S6vmji/PFDfbyITdm1WmtV45CfHV5vux/:15594:0:99999:7:::
- # usermod -e 2012-09-11 urchin
- # sed -n '$p' /etc/shadow
- urchin:$6$1PwPVBn5$o.MIEYONzURQPvn/YqSp69kt2CIASvXhOnjv/t \
- Z5m4NN6bJyLjCG7S6vmji/PFDfbyITdm1WmtV45CfHV5vux/:15594:0:99999:7::15594:
- # usermod -f 0 urchin
- # sed -n '$p' /etc/shadow
- urchin:$6$1PwPVBn5$o.MIEYONzURQPvn/YqSp69kt2CIASvXhOnjv/t \
- Z5m4NN6bJyLjCG7S6vmji/PFDfbyITdm1WmtV45CfHV5vux/:15594:0:99999:7:0:15594: