lastcomm Command

Purpose

Displays information about the last commands executed.

Syntax

lastcomm [ -X ][ Command ] [ Name ] [ Terminal ]

Description

The lastcomm command displays information, in reverse chronological order, about all previously executed commands that are still recorded in the /var/adm/pacct summary file. You need to run the /usr/sbin/acct/startup command before you can execute the lastcomm command.

The list the lastcomm command displays can be restricted to:

  • Commands specified by the Command parameter.
  • Commands executed by the user specified by the Name parameter.
  • Commands from the terminal specified by the Terminal parameter.

    A terminal can be named fully or abbreviated as a tty. For example, you can specify either the tty0 terminal or the 0 terminal.

For each process, the following information is displayed:

  • The name of the user who ran the process.
  • Any flags the accounting facilities collected when the command executed. The following are valid flags:
    Item Description
    S The root user executed the command.
    F The command ran after a fork, but without a following subroutine.
    C The command ran in PDP-11 compatibility mode.
    D The command terminated with the generation of a core file.
    X The command was terminated with a signal.
  • The name of the command under which the process was called.
  • The seconds of CPU time used by the process.
  • The time the process was started.

Flags

Item Description
-X Prints all available characters of each user name instead of truncating to the first 8 characters.

Examples

  1. To display information about all previously executed commands recorded in the /var/adm/pacct file, enter:
    lastcomm
  2. To display information about commands named a.out executed by the root user on the ttyd0 terminal, enter:
    lastcomm a.out root ttyd0
  3. To display information about all previously executed commands recorded in the /var/adm/pacct file without truncating the user name, enter:
    lastcomm -X

Files

Item Description
/usr/bin/lastcomm Contains the lastcomm command.
/var/adm/pacct The directory that contains the current accounting summary files.