LASTCOMM(1)

πŸ“¦
version 6.6.4 Β· 6 versions
, in alpine 3.22, alpine 3.23, alpine 3.24, debian bookworm, debian trixie, nixos 26.05, nixpkgs unstable, opensuse-leap 16.0, ubuntu jammy, ubuntu noble

✨ 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-user
    • F β€” command executed after a fork but without a following exec
    • C β€” command run in PDP-11 compatibility mode (VAX only)
    • D β€” command terminated with the generation of a core file
    • X β€” command was terminated with the signal SIGTERM
  • 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 -f arguments. 🚰
  • -f filename, --file filename β€” Read from the file filename instead of acct. A filename of "-" will result in reading from stdin. This must either be the first -f option, or --forwards must precede all -f options. ⚠️ order matters, bestie, don't play.
  • --ahz hz β€” Use this flag to tell the program what AHZ should be (in hertz). This option is useful if you are trying to view an acct file created on another machine which has the same byte order and file format as your current machine, but has a different value for AHZ. 🌍
  • -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, --pid shows 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 of lastcomm.
  • -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. See acct(5) (or pacct(5)) for further details.
  • /var/log/account β€” This directory contains pacct files 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 ⭐

last(1), acct(5)


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. πŸ’–βœ¨