> For the complete documentation index, see [llms.txt](https://book.bsdcn.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://book.bsdcn.org/man/man8/lastlogin.8.md).

# lastlogin.8

`lastlogin` — 显示用户的最近登录时间

## 名称

`lastlogin`

## 概要

`lastlogin [--libxo] [-f file] [-rt] [user ...]`

## 描述

`lastlogin` 工具将列出每个指定 `user` 的最近一次登录会话，默认情况下列出所有用户的。每行输出包含用户名、会话所使用的 tty、主机名（若有）以及会话的开始时间。

如果给出了多个 `user`，则按命令行中给出的顺序打印每个用户的会话信息。否则，将打印所有用户的信息。默认情况下，条目按用户名排序。

`lastlogin` 工具与 [last(1)](/man/man1/last.1.md) 的不同之处在于它仅打印关于最近一次登录会话的信息。在标准使用方式下，最近登录数据库从不会被轮转或删除。

可用选项如下：

**`--libxo`** 通过 libxo(3) 以多种人类和机器可读的格式生成输出。有关命令行参数的详细信息，请参见 xo\_options(7)。

**`-f`** `file` 打开指定的最近登录数据库 `file`，而非系统范围的数据库。

**`-r`** 以逆序打印条目。

**`-t`** 按最近登录时间排序，而非按用户名排序。

## 文件

**/var/log/utx.lastlogin** 最近登录数据库

## 参见

[last(1)](/man/man1/last.1.md), getutxent(3), libxo(3), xo\_options(7), ac(8)

## 作者

John M. Vinopal 于 1996 年 1 月编写了此程序并将其贡献给 NetBSD 项目。Philip Paeps 于 2018 年 8 月添加了 libxo(3) 支持。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://book.bsdcn.org/man/man8/lastlogin.8.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
