usermod:修改用户信息

xiaohai 2021-05-05 20:38:59 768人围观 标签: Linux 
简介usermod命令用户修改系统中已经存在的用户的账号信息
说明

  usermod命令用户修改系统中已经存在的用户的账号信息

格式

  usermod [option] [username]

常用参数(该命令可以使用useradd命令的参数,参见useradd命令章节)

-a:追加用户到用户组,仅与-G连用
-l:修改用户的账号名称
-L:锁定用户密码,不然用户修改密码
-U:解除密码锁定

示例
多参数联合使用
[root@localhost scripts]# usermod -u 888 -s /sbin/nologin -c TmpUser -G root,skip -e "2018-5-13" -f 30 -d /home/user_new3 user_new3
[root@localhost scripts]# id user_new3 #用户uid和gid信息
uid=888(user_new3) gid=9991(user_new3) groups=9991(user_new3),0(root),1002(skip)
[root@localhost scripts]# chage -l user_new3 #用户的过期时间信息
Last password change                    : May 08, 2018
Password expires                    : never
Password inactive                    : never
Account expires                        : May 13, 2018
Minimum number of days between password change        : 0
Maximum number of days between password change        : 99999
Number of days of warning before password expires    : 7
[root@localhost scripts]# tail -1 /etc/shadow #过期停权时间信息 30就是
user_new3:!!:17659:0:99999:7:30:17664: