• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • VCS
  • Interview Questions
  • Database
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

lastcomm: command not found

by Deepika

lastcomm is a command-line tool that shows a listing of the last commands executed on a Linux system. It is a part of the acct package and it reads the binary file that contains the list of executed commands, usually located at /var/log/pacct or /var/account/pacct.

The lastcomm command provides a list of all the executed commands on the system, including the date and time of the command, the username of the user who ran the command, and the command that was executed. The output can be useful for auditing and troubleshooting purposes, as it can help identify what commands have been executed, when, and by whom.

By default, the lastcomm command will show the most recent executed commands. You can also specify a time range or a specific username to filter the output. By using the -f option, you can specify a different location of the pacct file. It’s worth noting that the pacct file only keeps track of executed commands if process accounting is enabled on the system. To enable process accounting you should use the command accton.

If you encounter the below error while running the command lastcomm:

lastcomm: command not found

you may try installing the below package as per your choice of distribution:

Distribution Command
Debian apt-get install acct
Ubuntu apt-get install acct
Alpine apk add acct
Kali Linux apt-get install acct
CentOS yum install psacct
Fedora dnf install psacct
Raspbian apt-get install acct

lastcomm Command Examples

1. Print information about all the commands in the acct (record file):

# lastcomm

2. Display commands executed by a given user:

# lastcomm --user user

3. Display information about a given command executed on the system:

# lastcomm --command command

4. Display information about commands executed on a given terminal:

# lastcomm --tty terminal_name

Summary

In summary, lastcomm is a useful command-line tool for system administrators and security administrators who need to monitor executed commands on a Linux system. It can help identify potential security breaches and take appropriate action, as well as troubleshoot issues that may arise by checking the commands executed and their output.

Filed Under: Linux

Some more articles you might also be interested in …

  1. “git show-branch” Command Examples
  2. chntpw : command not found
  3. jtbl Command Examples
  4. rpm: Command Examples in Linux
  5. git diff: Show changes to tracked files
  6. dvc config: Low level command to manage custom configuration options for dvc repositories
  7. CentOS / RHEL : How to find Logical volumes (LVs) contained in Physical Volume (PVs) in LVM
  8. dotnet publish: Publish a .NET application and its dependencies to a directory for deployment to a hosting system
  9. btrfs inspect-internal Command Examples in Linux
  10. cvs: Concurrent Versions System, a revision control system

You May Also Like

Primary Sidebar

Recent Posts

  • Vanilla OS 2 Released: A New Era for Linux Enthusiasts
  • mk Command Examples
  • mixxx Command Examples
  • mix Command Examples

© 2025 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright