前言
你知道嗎,如何在 Linux 系統(tǒng)上查看帳戶的創(chuàng)建日期?如果知道,那么有些什么辦法。
你成功了么?如果是的話,該怎么做?
基本上 Linux 系統(tǒng)不會(huì)跟蹤這些信息,因此,獲取這些信息的替代方法是什么?
你可能會(huì)問(wèn)為什么我要查看這個(gè)?
是的,在某些情況下,你可能需要查看這些信息,那時(shí)就會(huì)對(duì)你會(huì)有幫助。
可以使用以下 7 種方法進(jìn)行驗(yàn)證。
使用 /var/log/secure 使用 aureport 工具 使用 .bash_logout 使用 chage 命令 使用 useradd 命令 使用 passwd 命令 使用 last 命令方式 1:使用 /var/log/secure
它存儲(chǔ)所有安全相關(guān)的消息,包括身份驗(yàn)證失敗和授權(quán)特權(quán)。它還會(huì)通過(guò)系統(tǒng)安全守護(hù)進(jìn)程跟蹤 sudo 登錄、SSH 登錄和其他錯(cuò)誤記錄。
# grep prakash /var/log/secureApr 12 04:07:18 centos.2daygeek.com useradd[21263]: new group: name=prakash, GID=501Apr 12 04:07:18 centos.2daygeek.com useradd[21263]: new user: name=prakash, UID=501, GID=501, home=/home/prakash, shell=/bin/bashApr 12 04:07:34 centos.2daygeek.com passwd: pam_unix(passwd:chauthtok): password changed for prakashApr 12 04:08:32 centos.2daygeek.com sshd[21269]: Accepted password for prakash from 103.5.134.167 port 60554 ssh2Apr 12 04:08:32 centos.2daygeek.com sshd[21269]: pam_unix(sshd:session): session opened for user prakash by (uid=0)
方式 2:使用 aureport 工具
aureport 工具可以根據(jù)記錄在審計(jì)日志中的事件記錄生成匯總和柱狀報(bào)告。默認(rèn)情況下,它會(huì)查詢 /var/log/audit/ 目錄中的所有 audit.log 文件來(lái)創(chuàng)建報(bào)告。
# aureport --auth | grep prakash46. 04/12/2018 04:08:32 prakash 103.5.134.167 ssh /usr/sbin/sshd yes 28847. 04/12/2018 04:08:32 prakash 103.5.134.167 ssh /usr/sbin/sshd yes 291
方式 3:使用 .bash_logout
家目錄中的 .bash_logout 對(duì) bash 有特殊的含義,它提供了一種在用戶退出系統(tǒng)時(shí)執(zhí)行命令的方式。
我們可以查看用戶家目錄中 .bash_logout 的更改日期。該文件是在用戶第一次注銷(xiāo)時(shí)創(chuàng)建的。
# stat /home/prakash/.bash_logout File: `/home/prakash/.bash_logout' Size: 18 Blocks: 8 IO Block: 4096 regular fileDevice: 801h/2049d Inode: 256153 Links: 1Access: (0644/-rw-r--r--) Uid: ( 501/ prakash) Gid: ( 501/ prakash)Access: 2017-03-22 20:15:00.000000000 -0400Modify: 2017-03-22 20:15:00.000000000 -0400Change: 2018-04-12 04:07:18.283000323 -0400
方式 4:使用 chage 命令
chage 意即 “change age”。該命令讓用戶管理密碼過(guò)期信息。chage 命令可以修改上次密碼更改日期后需要更改密碼的天數(shù)。
系統(tǒng)使用此信息來(lái)確定用戶何時(shí)必須更改其密碼。如果用戶自帳戶創(chuàng)建日期以來(lái)沒(méi)有更改密碼,這個(gè)就有用。
# chage --list prakashLast password change : Apr 12, 2018Password expires : neverPassword inactive : neverAccount expires : neverMinimum number of days between password change : 0Maximum number of days between password change : 99999Number of days of warning before password expires : 7
方式 5:使用 useradd 命令
新聞熱點(diǎn)
疑難解答
圖片精選