Candid photograph of a Linux server terminal with a soft olive-green glow against a dark slate background, conveying a calm technical atmosphere.

Step-by-step guides for system administrators — covering command-line basics, web server setup, and preparation material for technical interviews.

Browse Tutorials

Configuring system accounting with acct and lastcomm

Linux process accounting records executable activity at the operating-system level. It captures the user, terminal, execution time and exit status, producing a command-level history that remains useful when shell history is incomplete or has been cleared.

The software is commonly called acct, although RHEL, CentOS Stream and Fedora package it as psacct. On those distributions, the accounting file is usually /var/log/account/pacct, and lastcomm reads its binary records. Debian derivatives install the same tools through an acct package.

Process accounting is narrower than auditd: it answers which executable ran rather than documenting every file, socket or policy decision. Collection begins when the service is enabled and cannot reconstruct activity from before that moment.

A reliable setup combines an enabled service, tested queries, protected retention and careful handling of staff-related records in Australian organisations.

Component What it provides Useful command Main limitation
acct Enables kernel process accounting and manages the pacct log systemctl status acct Collection begins after activation
lastcomm Shows individual command records with user, terminal and timing sudo lastcomm -u alice It is not a complete system audit trail
ac Produces account usage totals by user or day sudo ac -p Aggregates hide the event sequence
sa Summarises command counts and CPU time sudo sa User and timing details are reduced

Installing and enabling process accounting

On RHEL-family systems, install psacct; Debian-family systems use acct. The systemd unit may be acct.service or psacct.service, so check the installed name. Australian RHEL, CentOS Stream and Fedora estates make these naming differences worth handling.

sudo dnf install psacct
systemctl list-unit-files 'acct.service' 'psacct.service'

Enable the unit reported by the second command. If it is acct.service, the usual sequence is:

sudo systemctl enable --now acct.service

Confirm the service and make a harmless test execution; it should appear in fresh output.

true
sudo systemctl is-active acct.service
sudo ls -lh /var/log/account/pacct
sudo lastcomm | head

RHEL-family packages often provide /etc/sysconfig/acct with the log location and related settings. Inspect shipped values before editing, then restart the service. Process accounting adds overhead and complements rather than replaces auditd.

Reading and interpreting account records

lastcomm converts accounting data into command, user, terminal, date and time fields. Unlike last, which reports login sessions from wtmp, it reports executable activity. Use -f to read another compatible file and optionally specify a command.

sudo lastcomm
sudo lastcomm -f /var/log/account/pacct sshd

Large exports are often easier to investigate in a desktop editor. The candidate-filtering approach in Helm or Ivy search shows how to narrow a long Magit-related list interactively; the same idea can be applied to a saved lastcomm report while retaining the raw accounting file as evidence.

For aggregate views, ac presents totals by user or day, while sa summarises command counts and CPU time. These are efficient for capacity reviews but lose the execution sequence, so use lastcomm when chronology matters.

Filtering activity for an investigation

lastcomm can narrow records by account, terminal or executable. These examples avoid scanning every entry when investigating a service login or particular operator.

sudo lastcomm -u alice
sudo lastcomm -t pts/0
sudo lastcomm sshd
sudo lastcomm | awk 'NR==1 || $1=="sudo" {print}'

Treat the user field as the effective UID, not proof of physical identity. Shared accounts, sudo, cron jobs and scripts can make actions look alike, while shell built-ins are not separate executable invocations. Correlate results with authentication logs, journalctl, wtmp and application logs.

Time interpretation deserves special care. Sydney and Melbourne move between AEST (UTC+10) and AEDT (UTC+11), Brisbane stays on UTC+10, and Perth uses UTC+8. Compare the host clock with UTC and record the zone; repeated local times around daylight-saving changes can otherwise mislead an investigator.

date -u
date
timedatectl

Retaining logs and scheduling reports

Treat the pacct file as evidence with a defined retention period. Check the distribution’s logrotate policy, including /etc/logrotate.d/acct, and preserve rotated accounting files for the required incident window. Use lastcomm -f against a protected copy when analysing an archived record rather than altering the original.

Daily or weekly summaries can be produced with a systemd timer or cron. The scheduling pattern in scheduled systemd reporting provides a practical way to generate a timestamped report, but restrict it with umask 077 and controlled output paths. Support handovers across Australian teams often cross Sydney, Melbourne, Brisbane and Perth within one business day, so filenames should include UTC and the source time zone.

Privacy controls for Australian systems

Command history may contain identifiable staff activity. The Privacy Act 1988 and Australian Privacy Principles can apply depending on the organisation and sector, while state or territory public-sector, health or employment rules may add obligations. Assess purpose, authority, notice, access and retention requirements with the organisation’s privacy or legal owner before enabling broad access.

Apply least privilege to /var/log/account/pacct and generated reports, audit who reads them, and avoid retaining them indefinitely. Command arguments are generally absent, but executable names, user IDs and timing can reveal sensitive projects or operational patterns. Secrets should never be encoded in a program or script name merely because process accounting omits arguments.

Collection should have a documented business need and a defensible deletion schedule. If monitoring is used for performance rather than misconduct, state that purpose plainly to affected staff and provide an approved process for access requests, correction and escalation.

A repeatable administration workflow

For adjacent command-line maintenance practices, the Linuxtpoint Linux guides provide useful background on Linux system administration. A repeatable review starts by confirming the unit, recording the accounting file path and running a known harmless command before trusting the output.

sudo systemctl is-active acct.service
sudo ls -lh /var/log/account/pacct
sudo lastcomm -u alice

For an incident, capture the exact query, host and UTC time window, then preserve both the raw output and relevant authentication records. lastcomm supplies a command execution timeline; it should be correlated with other logs before drawing conclusions about who performed an action.

The practical takeaway is to keep process accounting active, verify the live pacct file, filter with lastcomm, and apply the same access and retention controls used for other Australian audit data.