问题描述

在某些场景下,我们需要知道用户的创建时间。

比如 Jumpserver 推送用户到系统,我们想知道该用户是何时推送到系统的。

该笔记将记录:在系统中,如何确定用户的创建时间。

解决方法

方法有很,但都不是常规方法。

如果用户没有修改密码,可以使用如下方法(只能查看时间):

# passwd -S test
test P 12/03/2020 0 99999 7 -1

# chage -l k4nz 
Last password change                                    : Mar 16, 2020
Password expires                                        : never
Password inactive                                       : never
Account expires                                         : never
Minimum number of days between password change          : 0
Maximum number of days between password change          : 99999
Number of days of warning before password expires       : 7
	

通过系统日志获取:

// 	CentOS

# cat /var/log/secure | grep -i "<your username>"

// Ubuntu 18.04.4 LTS

# cat /var/log/auth.log | grep -E 'useradd.+test'
Dec  3 09:33:10 localhost useradd[13160]: new group: name=test, GID=1002
Dec  3 09:33:10 localhost useradd[13160]: new user: name=test, UID=1002, GID=1002, home=/home/test, shell=/bin/bash

创建用户的最佳实践

在创建用户时,建议使用 --comment 选项添加注释,并补充相关的信息。

参考文献

K4NZ/找到用户的创建时间
HowTo Find Linux User Created Date Is There Any Way - ARKIT


相关文章:

  • 2021-07-01
  • 2021-07-26
  • 2022-02-05
  • 2021-12-24
  • 2021-06-13
  • 2021-12-22
  • 2021-12-16
  • 2022-02-21
猜你喜欢
  • 2021-11-12
  • 2021-10-06
  • 2022-01-17
  • 2021-08-18
  • 2022-12-23
  • 2022-02-19
  • 2022-02-22
相关资源
相似解决方案