{"id":103264,"date":"2024-08-24T02:57:03","date_gmt":"2024-08-23T18:57:03","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=103264"},"modified":"2024-08-24T02:57:03","modified_gmt":"2024-08-23T18:57:03","slug":"display-user-createtime","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/display-user-createtime.html","title":{"rendered":"7\u4e2a\u65b9\u6cd5\u5e2e\u4f60\u67e5\u770bLinux\u7528\u6237\u7684\u6ce8\u518c\u65e5\u671f"},"content":{"rendered":"
\u4f60\u77e5\u9053\u5417\uff0c\u5982\u4f55\u5728 Linux \u7cfb\u7edf\u4e0a\u67e5\u770b\u5e10\u6237\u7684\u521b\u5efa\u65e5\u671f\uff1f\u5982\u679c\u77e5\u9053\uff0c\u90a3\u4e48\u6709\u4e9b\u4ec0\u4e48\u529e\u6cd5\u3002<\/p>\n
\u4f60\u6210\u529f\u4e86\u4e48\uff1f\u5982\u679c\u662f\u7684\u8bdd\uff0c\u8be5\u600e\u4e48\u505a\uff1f<\/p>\n
\u57fa\u672c\u4e0a Linux \u7cfb\u7edf\u4e0d\u4f1a\u8ddf\u8e2a\u8fd9\u4e9b\u4fe1\u606f\uff0c\u56e0\u6b64\uff0c\u83b7\u53d6\u8fd9\u4e9b\u4fe1\u606f\u7684\u66ff\u4ee3\u65b9\u6cd5\u662f\u4ec0\u4e48\uff1f<\/p>\n
\u4f60\u53ef\u80fd\u4f1a\u95ee\u4e3a\u4ec0\u4e48\u6211\u8981\u67e5\u770b\u8fd9\u4e2a\uff1f<\/p>\n
\u662f\u7684\uff0c\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u4f60\u53ef\u80fd\u9700\u8981\u67e5\u770b\u8fd9\u4e9b\u4fe1\u606f\uff0c\u90a3\u65f6\u5c31\u4f1a\u5bf9\u4f60\u4f1a\u6709\u5e2e\u52a9\u3002<\/p>\n
\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b 7 \u79cd\u65b9\u6cd5\u8fdb\u884c\u9a8c\u8bc1\u3002<\/p>\n
\u5b83\u5b58\u50a8\u6240\u6709\u5b89\u5168\u76f8\u5173\u7684\u6d88\u606f\uff0c\u5305\u62ec\u8eab\u4efd\u9a8c\u8bc1\u5931\u8d25\u548c\u6388\u6743\u7279\u6743\u3002\u5b83\u8fd8\u4f1a\u901a\u8fc7\u7cfb\u7edf\u5b89\u5168\u5b88\u62a4\u8fdb\u7a0b\u8ddf\u8e2a sudo \u767b\u5f55\u3001SSH \u767b\u5f55\u548c\u5176\u4ed6\u9519\u8bef\u8bb0\u5f55\u3002<\/p>\n
# grep prakash \/var\/log\/secure\r\nApr 12 04:07:18 centos.2daygeek.com useradd[21263]: new group: name=prakash, GID=501\r\nApr 12 04:07:18 centos.2daygeek.com useradd[21263]: new user: name=prakash, UID=501, GID=501, home=\/home\/prakash, shell=\/bin\/bash\r\nApr 12 04:07:34 centos.2daygeek.com passwd: pam_unix(passwd:chauthtok): password changed for prakash\r\nApr 12 04:08:32 centos.2daygeek.com sshd[21269]: Accepted password for prakash from 103.5.134.167 port 60554 ssh2\r\nApr 12 04:08:32 centos.2daygeek.com sshd[21269]: pam_unix(sshd:session): session opened for user prakash by (uid=0)<\/pre>\n\u65b9\u5f0f 2\uff1a\u4f7f\u7528 aureport \u5de5\u5177<\/strong><\/div>\naureport \u5de5\u5177\u53ef\u4ee5\u6839\u636e\u8bb0\u5f55\u5728\u5ba1\u8ba1\u65e5\u5fd7\u4e2d\u7684\u4e8b\u4ef6\u8bb0\u5f55\u751f\u6210\u6c47\u603b\u548c\u67f1\u72b6\u62a5\u544a\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u5b83\u4f1a\u67e5\u8be2 \/var\/log\/audit\/ \u76ee\u5f55\u4e2d\u7684\u6240\u6709 audit.log \u6587\u4ef6\u6765\u521b\u5efa\u62a5\u544a\u3002<\/p>\n
# aureport --auth | grep prakash\r\n46. 04\/12\/2018 04:08:32 prakash 103.5.134.167 ssh \/usr\/sbin\/sshd yes 288\r\n47. 04\/12\/2018 04:08:32 prakash 103.5.134.167 ssh \/usr\/sbin\/sshd yes 291<\/pre>\n\u65b9\u5f0f 3\uff1a\u4f7f\u7528 .bash_logout<\/strong><\/div>\n\u5bb6\u76ee\u5f55\u4e2d\u7684 .bash_logout \u5bf9 bash \u6709\u7279\u6b8a\u7684\u542b\u4e49\uff0c\u5b83\u63d0\u4f9b\u4e86\u4e00\u79cd\u5728\u7528\u6237\u9000\u51fa\u7cfb\u7edf\u65f6\u6267\u884c\u547d\u4ee4\u7684\u65b9\u5f0f\u3002<\/p>\n
\u6211\u4eec\u53ef\u4ee5\u67e5\u770b\u7528\u6237\u5bb6\u76ee\u5f55\u4e2d .bash_logout \u7684\u66f4\u6539\u65e5\u671f\u3002\u8be5\u6587\u4ef6\u662f\u5728\u7528\u6237\u7b2c\u4e00\u6b21\u6ce8\u9500\u65f6\u521b\u5efa\u7684\u3002<\/p>\n
\r\n# stat \/home\/prakash\/.bash_logout\r\n File: `\/home\/prakash\/.bash_logout'\r\n Size: 18 Blocks: 8 IO Block: 4096 regular file\r\nDevice: 801h\/2049d Inode: 256153 Links: 1\r\nAccess: (0644\/-rw-r--r--) Uid: ( 501\/ prakash) Gid: ( 501\/ prakash)\r\nAccess: 2017-03-22 20:15:00.000000000 -0400\r\nModify: 2017-03-22 20:15:00.000000000 -0400\r\nChange: 2018-04-12 04:07:18.283000323 -0400\r\n<\/pre>\n\u65b9\u5f0f 4\uff1a\u4f7f\u7528 chage \u547d\u4ee4<\/strong><\/div>\nchage \u610f\u5373 \u201cchange age\u201d\u3002\u8be5\u547d\u4ee4\u8ba9\u7528\u6237\u7ba1\u7406\u5bc6\u7801\u8fc7\u671f\u4fe1\u606f\u3002chage \u547d\u4ee4\u53ef\u4ee5\u4fee\u6539\u4e0a\u6b21\u5bc6\u7801\u66f4\u6539\u65e5\u671f\u540e\u9700\u8981\u66f4\u6539\u5bc6\u7801\u7684\u5929\u6570\u3002<\/p>\n
\u7cfb\u7edf\u4f7f\u7528\u6b64\u4fe1\u606f\u6765\u786e\u5b9a\u7528\u6237\u4f55\u65f6\u5fc5\u987b\u66f4\u6539\u5176\u5bc6\u7801\u3002\u5982\u679c\u7528\u6237\u81ea\u5e10\u6237\u521b\u5efa\u65e5\u671f\u4ee5\u6765\u6ca1\u6709\u66f4\u6539\u5bc6\u7801\uff0c\u8fd9\u4e2a\u5c31\u6709\u7528\u3002<\/p>\n
\r\n# chage --list prakash\r\nLast password change : Apr 12, 2018\r\nPassword expires : never\r\nPassword inactive : never\r\nAccount expires : never\r\nMinimum number of days between password change : 0\r\nMaximum number of days between password change : 99999\r\nNumber of days of warning before password expires : 7\r\n<\/pre>\n\u65b9\u5f0f 5\uff1a\u4f7f\u7528 useradd \u547d\u4ee4<\/strong><\/div>\nuseradd \u547d\u4ee4\u7528\u4e8e\u5728 Linux \u4e2d\u521b\u5efa\u65b0\u5e10\u6237\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u5b83\u4e0d\u4f1a\u6dfb\u52a0\u7528\u6237\u521b\u5efa\u65e5\u671f\uff0c\u6211\u4eec\u5fc5\u987b\u4f7f\u7528 \u201c\u5907\u6ce8\u201d \u9009\u9879\u6dfb\u52a0\u65e5\u671f\u3002<\/p>\n
\r\n# useradd -m prakash -c `date +%Y\/%m\/%d`\r\n# grep prakash \/etc\/passwd\r\nprakash:x:501:501:2018\/04\/12:\/home\/prakash:\/bin\/bash\r\n<\/pre>\n\u65b9\u5f0f 6\uff1a\u4f7f\u7528 passwd \u547d\u4ee4<\/strong><\/div>\npasswd \u547d\u4ee4\u7528\u4e8e\u5c06\u5bc6\u7801\u5206\u914d\u7ed9\u672c\u5730\u5e10\u6237\u6216\u7528\u6237\u3002\u5982\u679c\u7528\u6237\u5728\u5e10\u6237\u521b\u5efa\u540e\u6ca1\u6709\u4fee\u6539\u5bc6\u7801\uff0c\u90a3\u4e48\u53ef\u4ee5\u4f7f\u7528 passwd \u547d\u4ee4\u67e5\u770b\u6700\u540e\u4e00\u6b21\u5bc6\u7801\u4fee\u6539\u7684\u65e5\u671f\u3002<\/p>\n
\r\n# passwd -S prakash\r\nprakash PS 2018-04-11 0 99999 7 -1 (Password set, MD5 crypt.)<\/pre>\n\u65b9\u5f0f 7\uff1a\u4f7f\u7528 last \u547d\u4ee4<\/strong><\/div>\nlast \u547d\u4ee4\u8bfb\u53d6 \/var\/log\/wtmp\uff0c\u5e76\u663e\u793a\u81ea\u8be5\u6587\u4ef6\u521b\u5efa\u4ee5\u6765\u6240\u6709\u767b\u5f55\uff08\u548c\u9000\u51fa\uff09\u7528\u6237\u7684\u5217\u8868\u3002<\/p>\n
\r\n# last | grep \"prakash\"\r\nprakash pts\/2 103.5.134.167 Thu Apr 12 04:08 still logged in<\/pre>\nvia: https:\/\/www.2daygeek.com\/how-to-check-user-created-date-on-linux\/<\/p>\n
\u4f5c\u8005\uff1aPrakash Subramanian \u9009\u9898\uff1alujun9972 \u8bd1\u8005\uff1ageekpi \u6821\u5bf9\uff1awxy<\/p>\n
\u672c\u6587\u7531 LCTT \u539f\u521b\u7f16\u8bd1\uff0cLinux\u4e2d\u56fd \u8363\u8a89\u63a8\u51fa<\/p>\n
\n\u539f\u6587\u6765\u81ea\uff1ahttps:\/\/linux.cn\/article-9624-1.html<\/a><\/p>\n