自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

如何在Linux上檢查所有用戶密碼到期日期

系統(tǒng) Linux
如果你在 Linux 上啟用了密碼策略。密碼必須在到期前進(jìn)行更改,并且登錄到系統(tǒng)時(shí)會(huì)收到通知。如果你很少使用自己的帳戶,那么可能由于密碼過期而被鎖定。在許多情況下,這可能會(huì)在無需密碼登錄的服務(wù)帳戶中發(fā)生,因?yàn)闆]人會(huì)注意到它。

[[320664]]

如果你在 Linux 上啟用了密碼策略。密碼必須在到期前進(jìn)行更改,并且登錄到系統(tǒng)時(shí)會(huì)收到通知。

如果你很少使用自己的帳戶,那么可能由于密碼過期而被鎖定。在許多情況下,這可能會(huì)在無需密碼登錄的服務(wù)帳戶中發(fā)生,因?yàn)闆]人會(huì)注意到它。

這將導(dǎo)致停止服務(wù)器上配置的 cronjob/crontab。

如果如此,該如何緩解這種情況。

你可以寫一個(gè) shell 腳本來獲得有關(guān)它的通知,我們前一段時(shí)間為此寫了一篇文章。

它將給出天數(shù),但是本文旨在在終端中給你實(shí)際日期。

這可以使用 chage 命令來實(shí)現(xiàn)。

什么是 chage 命令?

chage 代表更改時(shí)效change age。它更改用戶密碼到期信息。

chage 命令可以修改兩次密碼更改之間的天數(shù),以及最后一次更改密碼的日期。

系統(tǒng)使用此信息來確定用戶何時(shí)應(yīng)更改密碼。

它還允許用戶執(zhí)行其他功能,例如設(shè)置帳戶到期日期、在到期后將密碼設(shè)置為無效、顯示帳戶時(shí)效信息、設(shè)置密碼更改之前的最小和最大天數(shù)以及設(shè)置到期警告天數(shù)。

1)如何在 Linux 上檢查特定用戶的密碼到期日期

如果要檢查 Linux 上特定用戶的密碼到期日期,請(qǐng)使用以下命令。

  1. # chage -l daygeek
  2.  
  3. Last password change : Feb 13, 2020
  4. Password expires : May 13, 2020
  5. Password inactive : never
  6. Account expires : never
  7. Minimum number of days between password change : 7
  8. Maximum number of days between password change : 90
  9. Number of days of warning before password expires : 7

2)如何在 Linux 上檢查所有用戶的密碼到期日期

你可以直接對(duì)單個(gè)用戶使用 chage 命令,不過可能你對(duì)多個(gè)用戶使用時(shí)可能無效。

為此,你需要編寫一個(gè)小的 shell 腳本。下面的 shell 腳本可以列出添加到系統(tǒng)中的所有用戶,包括系統(tǒng)用戶。

  1. # for user in $(cat /etc/passwd |cut -d: -f1); do echo $user; chage -l $user | grep "Password expires"; done | paste -d " " - - | sed 's/Password expires//g'

你將得到類似以下的輸出,但是用戶名可能不同。

  1. root : never
  2. bin : never
  3. daemon : never
  4. adm : never
  5. lp : never
  6. sync : never
  7. shutdown : never
  8. u1 : Nov 12, 2018
  9. u2 : Jun 17, 2019
  10. u3 : Jun 17, 2019
  11. u4 : Jun 17, 2019
  12. u5 : Jun 17, 2019

3)如何檢查 Linux 上除系統(tǒng)用戶外的所有用戶的密碼有效期

下面的 shell 腳本將顯示有到期日期的用戶列表。

  1. # for user in $(cat /etc/passwd |cut -d: -f1); do echo $user; chage -l $user | grep "Password expires"; done | paste -d " " - - | sed 's/Password expires//g' | grep -v "never"

你將得到類似以下的輸出,但是用戶名可能不同。

  1. u1 : Nov 12, 2018
  2. u2 : Jun 17, 2019
  3. u3 : Jun 17, 2019
  4. u4 : Jun 17, 2019
  5. u5 : Jun 17, 2019

 

責(zé)任編輯:龐桂玉 來源: Linux中國
相關(guān)推薦

2018-07-20 14:20:24

Linux用戶組管理員

2018-05-10 15:05:41

Linux用戶日期命令

2022-05-10 07:20:18

Linux系統(tǒng)密碼

2009-07-21 11:11:44

刪除CookieASP.NET

2020-04-30 13:50:11

Linux網(wǎng)卡信息

2022-01-17 13:34:45

MySQLLinux數(shù)據(jù)庫

2023-03-25 20:02:40

微軟Windows 1

2022-04-23 16:36:30

Linux密碼

2020-11-17 11:19:48

Linux磁盤空間

2018-08-02 09:50:47

Linux命令用戶信息

2017-10-17 14:33:41

2023-04-29 18:35:05

微軟Windows 11虛擬機(jī)

2019-03-18 09:00:04

Linux密碼cracklib

2022-04-20 10:25:27

Linux用戶密碼命令

2024-02-19 11:31:55

Linux系統(tǒng)用戶登錄

2022-10-28 16:42:04

Linuxcrontab日志

2014-06-09 10:23:20

2019-01-07 09:50:06

Linuxtarball命令

2019-11-26 16:58:51

Linuxpkgsrc

2019-11-26 09:20:47

LinuxJava
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)