#Bash 的 utmpdump 命令
utmpdump [OPTION]... FILENAME
功能
转储 UTMP 或 WTMP 文件(用户登录日志)。
类型
可执行文件(/usr/bin/utmpdump),属于 util-linux。
参数
OPTION选项:-f,--follow- 持续转储文件的追加内容-o,--output file- 转储到file文件中,而不是打印到标准输出-r,--reverse- 方向操作,将file反向写回 UTMP 或 WTMP 文件-h,--help- 显示帮助-V,--version- 显示版本
FILENAME- UTMP 或 WTMP 文件
#示例
$ utmpdump -f /var/log/wtmp # 持续监控 wtmp
Utmp dump of /var/log/wtmp
[7] [2760293] [ts/5] [primers ] [pts/5 ] [192.168.1.100 ] [192.168.1.100 ] [2026-03-02T18:10:57,185538+00:00]
[8] [2347153] [ ] [ ] [pts/1 ] [ ] [0.0.0.0 ] [2026-03-03T15:14:54,064908+00:00]
[7] [3040115] [ts/1] [primers ] [pts/1 ] [192.168.1.100 ] [192.168.1.100 ] [2026-03-03T15:14:57,605562+00:00]
#推荐阅读
#手册
UTMPDUMP(1) User Commands UTMPDUMP(1)
NAME
utmpdump - dump UTMP and WTMP files in raw format
SYNOPSIS
utmpdump [options] filename
DESCRIPTION
utmpdump is a simple program to dump UTMP and WTMP files in raw format,
so they can be examined. utmpdump reads from stdin unless a filename is
passed.
OPTIONS
-f, --follow
Output appended data as the file grows.
-o, --output file
Write command output to file instead of standard output.
-r, --reverse
Undump, write back edited login information into the utmp or wtmp
files.
-h, --help
Display help text and exit.
-V, --version
Print version and exit.
NOTES
utmpdump can be useful in cases of corrupted utmp or wtmp entries. It
can dump out utmp/wtmp to an ASCII file, which can then be edited to
remove bogus entries, and reintegrated using:
utmpdump -r < ascii_file > wtmp
But be warned, utmpdump was written for debugging purposes only.
File formats
Only the binary version of the utmp(5) is standardised. Textual dumps
may become incompatible in future.
The version 2.28 was the last one that printed text output using
ctime(3) timestamp format. Newer dumps use millisecond precision
ISO-8601 timestamp format in UTC-0 timezone. Conversion from former
timestamp format can be made to binary, although attempt to do so can
lead the timestamps to drift amount of timezone offset.
BUGS
You may not use the -r option, as the format for the utmp/wtmp files
strongly depends on the input format. This tool was not written for
normal use, but for debugging only.
AUTHORS
Michael Krapp
SEE ALSO
last(1), w(1), who(1), utmp(5)
REPORTING BUGS
For bug reports, use the issue tracker at
https://github.com/util-linux/util-linux/issues.
AVAILABILITY
The utmpdump command is part of the util-linux package which can be
downloaded from Linux Kernel Archive
<https://www.kernel.org/pub/linux/utils/util-linux/>.
util-linux 2.39.3 2023-10-23 UTMPDUMP(1)