Linux 用户管理(二)
一、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. 示例: - 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
案例:批量更改用户密码 批量创建10个用户stu01-stu10,并且设置随机8位密码,要求不能用shell的循环(例如:for,while等),只能用linux命令及管道实现
四、chage --change user password expiry information 修改用户密码有效期
- -i --list 显示相关信息
- -E --expiredate 账号过期时间
- 其他参数功能和passwd相同,可以用passwd 替代
最新文章
- Attribute操作的性能优化方式
- MVC中使用[ValidateAntiForgeryToken]防止CSRF 注入攻击
- 用node搭建静态文件服务器
- 在Windows上将ReactNative集成到现有的Android项目
- js动画之简单运动二
- Android 自动生成表格
- Android addRule()
- Jordan Lecture Note-12: Kernel典型相关分析(Kernel Canonical Correlation Analysis, KCCA).
- 一步一步学习SignalR进行实时通信_5_Hub
- 17.4.3 使用MulticastSocket实现多点广播(4)
- css布局与盒子模型
- fzu 2257 saya的小熊饼干
- MySQL binlog相关分析
- Go中局部全局变量的区分
- C#版微信公众号支付|微信H5支付|微信扫码支付问题汇总及解决方案总结
- jQuery实现淘宝购物车小组件
- odoo订餐系统之菜单设计
- windows php7 安装 mongodb 扩展
- 2017.6.5项目总结(移动端touch事件)
- NALU数据打RTP包流程详解