LASTCOMM(1)
β¨ lastcomm(1) β like, the whole β¨vibeβ¨ of your command history, but make it forensics π
okay bestie, so this is lastcomm, and it lives in the General Commands Manual section of your Unix system. She's a little archivist π β she digs through your system's accounting records and tells you who ran what, when, and as whom. No cap.
πΈ NAME πΈ
lastcomm β print out information about previously executed commands.
π¦ SYNOPSIS π¦
lastcomm
[ command-name ... ]
[ user-name ... ]
[ terminal-name ... ]
[ OPTION ... ]
π DESCRIPTION π
Okay so here's the tea. lastcomm prints out information about previously executed commands. π΅οΈβοΈ
If you give it no arguments at all, it will print info about all of the commands in acct (that's the record file, bestie β the receipts π).
But if you call it with one or more of command-name, user-name, or terminal-name, then only records containing those items will be displayed. Like, filter mode: activated. β¨
For example, to find out which users used command a.out and which users were logged into tty0, you'd type:
lastcomm a.out tty0
This will print any entry for which a.out or tty0 matches in any of the record's fields (command, name, or terminal). It's giving "OR" energy, fr fr. π₯
But wait β if you want to find only items that match *all* of the arguments on the command line, you MUST use the -strict-match option. No shortcuts. It's giving "AND" energy now. π
For example, to list all of the executions of command a.out by user root on terminal tty0, type:
lastcomm --strict-match --command a.out --user root --tty tty0
The order of the arguments is not important. π«Ά She's flexible like that.
π what she prints for each entry π
For each entry the following information is printed:
- command name of the process
- flags, as recorded by the system accounting routines:
Sβ command executed by super-userFβ command executed after a fork but without a following execCβ command run in PDP-11 compatibility mode (VAX only)Dβ command terminated with the generation of a core fileXβ command was terminated with the signalSIGTERM
- the name of the user who ran the process
- time the process started
π OPTIONS π
--strict-matchβ Print only entries that match *all* of the arguments on the command line.--print-controlsβ Print control characters.--user nameβ List records for user with name. This is useful if you're trying to match a username that happens to be the same as a command (e.g.,ed).--command nameβ List records for command name.--tty nameβ List records for tty name.--forwardsβ Read file forwards instead of backwards. This avoids trying to seek on the file and can be used to read from a pipe. This must be specified prior to any-farguments. π°-f filename,--file filenameβ Read from the file filename instead ofacct. A filename of"-"will result in reading from stdin. This must either be the first-foption, or--forwardsmust precede all-foptions. β οΈ order matters, bestie, don't play.--ahz hzβ Use this flag to tell the program whatAHZshould be (in hertz). This option is useful if you are trying to view anacctfile created on another machine which has the same byte order and file format as your current machine, but has a different value forAHZ. π-p,--show-pagingβ Print paging statistics.--pidβ Show PID and PPID of the process if acct version 3 format is supported by kernel.--pidβ Add pid of the process and pid of the process parent to the output (pid is the last but one and parent pid the last column). These values are shown only when they are generated by acct function (depends on the version of kernel). π―βοΈ (yes,--pidshows up twice in the original β that's iconic, we don't fix it, we respect it)--debugβ Print verbose internal information. π-V,--versionβ Print the version number oflastcomm.-h,--helpβ Prints the usage string and default locations of system files to standard output and exits.
π FILES π
acctβ The system wide process accounting file. Seeacct(5)(orpacct(5)) for further details./var/log/accountβ This directory containspacctfiles which contain the binary process accounting data as written by the kernel. πΎ
π AUTHOR π
The GNU accounting utilities were written by Noel Cragg <noel@gnu.ai.mit.edu>. The man page was adapted from the accounting texinfo page by Susan Kleinmann <sgk@sgk.tiac.net>.
Shoutout to the icons who wrote the docs, periodt. π
β SEE ALSO β
and that's the whole page, bestie π₯° she's from the General Commands Manual, dated 1995 October 31 β a true vintage queen, LASTCOMM(1), still serving looks and still telling you exactly who ran a.out on tty0. slay. πβ¨
π¦ where this page comes from
- alpine 3.22: acct-doc 6.6.4-r2 Β· GPL-3.0-or-later
- alpine 3.23: acct-doc 6.6.4-r2 Β· GPL-3.0-or-later
- alpine 3.24: acct-doc 6.6.4-r2 Β· GPL-3.0-or-later
- debian bookworm: acct 6.6.4-5+b1 Β· GPL-3.0-only
- debian trixie: acct 6.6.4-8 Β· GPL-3.0-only
- nixos 26.05: acct 6.6.4
- nixpkgs unstable: acct 6.6.4
- opensuse-leap 16.0: acct 6.6.4-bp160.1.13 Β· GPL-2.0-or-later
- opensuse-leap 16.0: acct 6.6.4-bp160.1.13 Β· GPL-2.0-or-later
- opensuse-leap 16.0: acct 6.6.4-bp160.1.13 Β· GPL-2.0-or-later
- opensuse-leap 16.0: acct 6.6.4-bp160.1.13 Β· GPL-2.0-or-later
- ubuntu jammy: acct 6.6.4-4build2 Β· GPL-3.0-only
- ubuntu noble: acct 6.6.4-5build1 Β· GPL-3.0-only
- ubuntu noble: acct 6.6.4-5ubuntu0.24.04.1 Β· GPL-3.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms