[译]使用chage来管理Linux密码过期时间的七个例子
本文译自 7 Examples to Manage Linux Password Expiration and Aging Using chage
本文主要介绍命令chage的使用,译文会对原文内容会有一定的简化。
debian系统可以通过如下命令安装chage: (chage is for change age)
apt-get install chage
CentOS7 应该是自带这个命令了。
列出用户密码相关信息
Syntax: chage –-list username (or) chage -l username $ chage --list dhinesh
Last password change : Apr ,
Password expires : never
Password inactive : never
Account expires : never
Minimum number of days between password change :
Maximum number of days between password change :
Number of days of warning before password expires :
注:普通用户对其它用户执行这条命令,但root用户可以
修改下密码
$ date
Thu Apr :: PDT $ passwd dhinesh
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully $ chage --list dhinesh
Last password change : Apr ,
Password expires : never
Password inactive : never
Account expires : never
Minimum number of days between password change :
Maximum number of days between password change :
Number of days of warning before password expires :
可以看出上次密码修改的时间已经发生了变化。
通过选项-M 设置账户密码的到期时间
Syntax: # chage -M number-of-days username # chage -M dhinesh # chage --list dhinesh
Last password change : Apr ,
Password expires : May ,
Password inactive : never
Account expires : never
Minimum number of days between password change :
Maximum number of days between password change :
Number of days of warning before password expires :
密码到期时间变成了十天后。
密码过期消息提醒
如上,密码过期之前7天会提示密码过期,假如dhinesh 试图在Apr 30, 2009登录,那么将会出现如下提醒消息:
$ ssh dhinesh@testingserver
dhinesh@testingserver's password:
Warning: your password will expire in days
密码过期时,强制用户修改密码
$ ssh dhinesh@testingserver
dhinesh@testingserver's password:
You are required to change your password immediately (password aged)
WARNING: Your password has expired.
You must change your password now and login again!
Changing password for dhinesh
(current) UNIX password:
Enter new UNIX password:
Retype new UNIX password:
设置账户过期时间
可以使用-E选项设置账户的过期时间,时间格式为“YYYY-MM-DD”。
# chage -E "2009-05-31" dhinesh # chage -l dhinesh
Last password change : Apr ,
Password expires : May ,
Password inactive : never
Account expires : May ,
Minimum number of days between password change :
Maximum number of days between password change :
Number of days of warning before password expires :
设置用户不活跃锁定
当用户密码过期后,可以设置用户多少天不活跃即锁定账户,如10天。
# chage -I dhinesh # chage -l dhinesh
Last password change : Apr ,
Password expires : May ,
Password inactive : May ,
Account expires : May ,
Minimum number of days between password change :
Maximum number of days between password change :
Number of days of warning before password expires :
设置用户账户不过期
取消用户账户过期设置。
-m will set the minimum number of days between password change to
-M will set the maximum number of days between password change to
-I - (number minus one) will set the “Password inactive” to never
-E - (number minus one) will set “Account expires” to never.
# chage -m -M -I - -E - dhinesh # chage --list dhinesh
Last password change : Apr ,
Password expires : never
Password inactive : never
Account expires : never
Minimum number of days between password change :
Maximum number of days between password change :
Number of days of warning before password expires :
以上!
[译]使用chage来管理Linux密码过期时间的七个例子的更多相关文章
- linux 用户密码过期时间
/etc/login.defs 全局配置文件,即当新建用户时的默认设置 PASS_MIN_DAYS 5 #最近一次密码更新的日期+0 ,即允许用户更改自己的密码的日期 PASS_MAX_ ...
- Linux 密码过期(WARNING:Your password has expired )
最近遇到两次这个问题,我们公司用的是开源的堡垒机Jumpserver但是最近有两个同学遇到了 WARNING:Your password has expired 第一次遇到这个问题也没有往深了去查,当 ...
- oracle修改用户密码过期时间
Oracle默认在default概要文件中设置了“PASSWORD_LIFE_TIME=180天”,导致密码过期,程序无法使用,业务进程会提示无法连接数据库等字样. --查询默认密码过期时间 SELE ...
- (Oracle)数据库用户的密码过期时间如何修改为永不过期
Oracle的密码过期规则是用Profile来管理的,系统默认只有一个Profile(DEFAULT),该profile的密码过期规则为180天.那么如何修改Oracle数据库用户的密码过期时间为永不 ...
- Oracle密码概要文件,密码过期时间180天修改为3天,相关用户密码是否过期
#Oracle用户密码,概要文件修改测试 #默认的用户使用概要文件,默认概要文件密码过期时间参数180天,修改为3天,对于老的用户来说,是密码过期,还是未发生改变, 对于新用户来说,新设置的密码过期时 ...
- Sqlserver 密码过期时间查询
DECLARE @login nvarchar(30) -- 查询设定密码过期的登陆账号SELECT @login = nameFROM sys.sql_loginsWHERE is_expirati ...
- 解除 linux 账户过期时间
riyimei:~ # chage -E 2019/01/01 li Aging information changed. riyimei:~ # cat /etc/shadow |grep li l ...
- linux初级学习笔记七:linux用户管理,密码和组命令详解!(视频序号:04_1)
本节学习的命令: 用户管理命令:useradd,userdel,id,finger,usermod,chsh,chfn,passwd,pwck, 组管理命令:groupadd,groupmod,gro ...
- 用户管理-linux基础
用户管理 useradd -u -g -G(附加组) ,-c -d -s -r(创建系统用户) -M (不创建家目录) 思考:删除user1用户家目录,如何还原. 可以#cp ...
随机推荐
- 1094. The Largest Generation (25)-(dfs,树的遍历,统计每层的节点数)
题目很简单,就是统计一下每层的节点数,输出节点数最多的个数和对应的层数即可. #include <iostream> #include <cstdio> #include &l ...
- 《Linux内核分析》第五周:分析system_call中断处理过程
实验 分析system_call中断处理过程 使用gdb跟踪分析一个系统调用内核函数(您上周选择那一个系统调用),系统调用列表参见http://codelab.shiyanlou.com/xref/l ...
- UIO,大页内存,CPU亲和性,NUMA机制等
Linux环境下的UIO(Userspace I/O) UIO 用户空间下驱动程序的支持机制.DPDK使用UIO机制使网卡驱动程序运行在用户态,并采用轮询和零拷贝方式从网卡收取报文,提高收发报文的性能 ...
- ElasticSearch 2 (28) - 信息聚合系列之高层概念
ElasticSearch 2 (28) - 信息聚合系列之高层概念 摘要 和查询表达式(query DSL)一样,聚合也有一种可编辑的语法:可以根据我们的需要混合以及匹配使用独立的功能单元.这也就是 ...
- Elasticsearch学习系列之term和match查询
lasticsearch查询模式 一种是像传递URL参数一样去传递查询语句,被称为简单查询 GET /library/books/_search //查询index为library,type为book ...
- php排序学习之-冒泡排序
原理:对一组数据,比较相邻数据的大小,将值小数据在前面,值大的数据放在后面. (以下都是升序排列,即从小到大排列) 举例说明: $arr = array(6, 3, 8, 2, 9, 1); $a ...
- Python的数据结构
目录 Python内置的数据结构 序列Sequence 映射Mapping 集合Sets Python内置的数据结构 Python语言简洁明了,可以用较少的代码实现同样的功能.这其中Python内置的 ...
- [国家集训队]middle
[国家集训队]middle 题目 解法 开\(n\)颗线段树,将第\(i\)颗线段树中大于等于第\(i\)小的数权值赋为1,其他的则为-1,对于每个区间维护一个区间和,最大前缀和,最大后缀和. 然后二 ...
- 洛谷 P1073 最优贸易 解题报告
P1073 最优贸易 题目描述 \(C\)国有\(n\)个大城市和\(m\)条道路,每条道路连接这\(n\)个城市中的某两个城市.任意两个城市之间最多只有一条道路直接相连.这\(m\)条道路中有一部分 ...
- 进程和线程(3)-ThreadLocal
ThreadLocal 在多线程环境下,每个线程都有自己的数据.一个线程使用自己的局部变量比使用全局变量好,因为局部变量只有线程自己能看见,不会影响其他线程,而全局变量的修改必须加锁. 但是局部变量也 ...