一、groupadd  --create a new group 创建新用户

  • -g  --gid GID

二、groupdel  --delete a group

三、passwd  --update user's authentication tokens 更改用户密码

  • 主要更改的文件:/etc/shadow 
  • --stdin 

    This option is used to indicate that passwd should read the new
    password from standard input, which can be a pipe.  示例:

  • 案例:批量更改用户密码   批量创建10个用户stu01-stu10,并且设置随机8位密码,要求不能用shell的循环(例如:for,while等),只能用linux命令及管道实现

    • echo stu{01..10}|tr " " "\n"|sed -r 's#(.*)#useradd \1 ; pass=$((RANDOM+10000000)); echo "$pass"|passwd --stdin \1; echo -e "\1 \t `echo "$pass"`">>/tmp/oldboy.log#g'|bash
    • 上述命令实际就是再拼N条下面的命令的组合,举一条命令stu01用户的过程拆解如下:
      useradd stu01 ; 
      pass=$((RANDOM+10000000)); 
      echo "$pass"|passwd --stdin stu01; 
      echo -e "stu01        `echo "$pass"`">>/tmp/oldboy.log
      特别说明:如果用shell循环结构会更简单,之所以限制使用循环的目的是锻炼学生的基础命令运用
      能力,学到现在还没学到SHELL循环课程呢  地址:https://user.qzone.qq.com/49000448/blog/1422183723?_t_=0.5695657615591867
  • -n This will set the minimum password lifetime, in days, if the
    user’s account supports password lifetimes. Available to root
    only. 规定多少天内不能修改密码

  • -x This will set the maximum password lifetime, in days, if the
    user’s account supports password lifetimes. Available to root
    only.规定多少天之后必须修改密码及密码过期时间=当前时间+x

  • -w This will set the number of days in advance the user will begin
    receiving warnings that her password will expire, if the user’s
    account supports password lifetimes. Available to root only. --过期w天之前提醒

  • -i This will set the number of days which will pass before an
    expired password for this account will be taken to mean that the
    account is inactive and should be disabled, if the user’s
    account supports password lifetimes. Available to root only.--密码失效时间即密码过期之后i天失效

  • 示例:账号test01 密码7天之内不能修改,60天之后必须修改,过期7天前提醒,过期10天后失效
    [root@gaogzhen ~]# passwd -n 7 -x 60 -w 7 -i 10  test01
    

四、chage  --change user password expiry information 修改用户密码有效期

  • -i  --list 显示相关信息
  • -E --expiredate 账号过期时间
  • 其他参数功能和passwd相同,可以用passwd 替代

最新文章

  1. Attribute操作的性能优化方式
  2. MVC中使用[ValidateAntiForgeryToken]防止CSRF 注入攻击
  3. 用node搭建静态文件服务器
  4. 在Windows上将ReactNative集成到现有的Android项目
  5. js动画之简单运动二
  6. Android 自动生成表格
  7. Android addRule()
  8. Jordan Lecture Note-12: Kernel典型相关分析(Kernel Canonical Correlation Analysis, KCCA).
  9. 一步一步学习SignalR进行实时通信_5_Hub
  10. 17.4.3 使用MulticastSocket实现多点广播(4)
  11. css布局与盒子模型
  12. fzu 2257 saya的小熊饼干
  13. MySQL binlog相关分析
  14. Go中局部全局变量的区分
  15. C#版微信公众号支付|微信H5支付|微信扫码支付问题汇总及解决方案总结
  16. jQuery实现淘宝购物车小组件
  17. odoo订餐系统之菜单设计
  18. windows php7 安装 mongodb 扩展
  19. 2017.6.5项目总结(移动端touch事件)
  20. NALU数据打RTP包流程详解

热门文章

  1. 集合中的 for-Each循环
  2. PHP+Mysql+jQuery找回密码
  3. 七,JOBC数据库编程
  4. 天上掉馅饼 期望DP
  5. asp.net重启web应用程序域
  6. log4j.properties配置详情
  7. java的三大特性之一封装概述
  8. 常用的 HTML 头部标签
  9. python os,sys模块的使用
  10. Python+selenium之键盘事件