← 返回命令列表

Linux command

lastlog 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Example

lastlog

Example

lastlog --user [username]

Example

lastlog --before [7]

Example

lastlog --time [3]

说明

lastlog reports the most recent login of all users or a specified user by reading /var/log/lastlog. Unlike last, it shows only one record per user representing their most recent login. The lastlog file is a sparse file indexed by UID, so it can appear large but doesn't consume much disk space. Users who have never logged in show "Never logged in".

参数

-u, --user _LOGIN|RANGE_
Show lastlog record for specified user(s). Can be a login name, numeric UID, or a UID range (UID_MIN-UID_MAX)
-b, --before _DAYS_
Show records older than DAYS
-t, --time _DAYS_
Show records more recent than DAYS
-C, --clear
Clear lastlog record for a user (requires -u)
-S, --set
Set lastlog record for a user to the current time (requires -u)
-R, --root _CHROOT\_DIR_
Apply changes in the CHROOT_DIR directory and use its configuration files
-h, --help
Display help message and exit

FAQ

What is the lastlog command used for?

lastlog reports the most recent login of all users or a specified user by reading /var/log/lastlog. Unlike last, it shows only one record per user representing their most recent login. The lastlog file is a sparse file indexed by UID, so it can appear large but doesn't consume much disk space. Users who have never logged in show "Never logged in".

How do I run a basic lastlog example?

Run `lastlog` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -u, --user _LOGIN|RANGE_ do in lastlog?

Show lastlog record for specified user(s). Can be a login name, numeric UID, or a UID range (UID_MIN-UID_MAX)