cmd
Enable command auditing on the server and view a report of the programs users have run
- Command:
/go/cmd - Category: Security
- Required option: None
- Output: Plain text audit report (also logged to
/var/log/go/cmd.log) - Last updated: 2026-11-20
On this page: Overview · Quick start · Syntax · Output · Examples · Troubleshooting · Details · See also
Overview
/go/cmd uses the Linux audit system (auditd) to record every program that is executed on the server, then reports on what was recorded. It works in two stages:
- First run: installs and configures auditing so that every program execution is logged under the key
exec_log, then shows the report (which will be empty at this point). - Later runs: only shows the report.
Quick start
# First run: enable command auditing
/go/cmd
# Later runs: view the report
/go/cmd
[!WARNING] The first run removes and reinstalls the
auditandaudit-libspackages and deletes every file in/etc/audit/rules.d/, including any audit rules you or your security tools added. Review/etc/audit/rules.d/before running it on a server that already uses auditing.
Syntax
/go/cmd
The command takes no options or arguments. Any you pass are ignored (they are only written to the log).
The same command does setup or reporting depending on whether /etc/audit/rules.d/cmd.rules exists.
| State | Behavior |
|---|---|
/etc/audit/rules.d/cmd.rules exists |
Prints the audit report. |
| It doesn't exist | Runs the setup, then prints the report. |
Output
The output comes from aureport -k, the audit key report. It lists one line per recorded event, with the date and time, the key, whether the call succeeded, the executable that ran, the numeric user ID of the person who ran it (auid), and the event number.
| Situation | What you see |
|---|---|
| Right after the first run | An empty report, because nothing has been recorded yet. |
| Later runs | One line for every program executed since auditing began, including those run by cron jobs and system services. |
| Setup problems | Errors from dnf or augenrules. |
The report shows the executable's path, not its arguments. To see full command lines, use ausearch (see Examples).
Every run is logged with a timestamp, for example [Nov 20 09:15:02]# cmd, to /var/log/go/cmd.log.
Examples
# Enable auditing (first run) or view the report
/go/cmd
# Show only a count per executable instead of every event
aureport -k --summary
# Show full command lines for today, with user names instead of numeric IDs
ausearch -k exec_log -i -ts today
# Show everything one user ran, by numeric user ID
ausearch -k exec_log -ua 1000 -i
# Check that auditing is running
systemctl status auditd
# Turn command logging off again
rm /etc/audit/rules.d/cmd.rules
augenrules --load
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
| The report is empty after setup | No programs have run since the rules loaded, or auditd isn't running. |
Run a few commands, then run /go/cmd again. Check with systemctl status auditd. |
dnf: command not found |
The server isn't a dnf-based system. |
The command supports AlmaLinux, Rocky, RHEL, Fedora, and CentOS versions that use dnf. See Supported systems. |
Permission denied when writing cmd.rules |
You aren't running as root. | Run it as root. |
dnf refuses to remove audit-libs, or wants to remove other packages |
Other packages depend on audit-libs. |
Don't confirm any removal of core packages. Install audit manually, create cmd.rules yourself, and run augenrules --load. |
| Custom audit rules disappeared | The first run deletes everything in /etc/audit/rules.d/. |
Recreate the rules in a separate file, then run augenrules --load. |
| The report is very long | Every program execution is recorded. | Use aureport -k --summary, or ausearch -k exec_log -ts today. |
/var/log/audit is using a lot of disk space |
Logging every execution produces a lot of data. | Adjust log size and rotation in /etc/audit/auditd.conf, or turn logging off. |
| Setup didn't run again | cmd.rules already exists. |
Delete /etc/audit/rules.d/cmd.rules and run /go/cmd again. |
Details
Setup steps
When /etc/audit/rules.d/cmd.rules doesn't exist, the command:
- Removes the
auditandaudit-libspackages withdnf. - Deletes every file in
/etc/audit/rules.d/. - Installs
auditandaudit-libsagain. - Writes
/etc/audit/rules.d/cmd.ruleswith the two rules below. - Loads the rules with
augenrules --load. - Prints the report with
aureport -k.
-a always,exit -F arch=b64 -S execve -k exec_log
-a always,exit -F arch=b32 -S execve -k exec_log
Each rule logs every execve system call, which is how Linux starts a program, for 64-bit and 32-bit programs, and tags the events with the key exec_log.
The command doesn't enable or restart auditd. If the service isn't running after the reinstall, start it with systemctl enable --now auditd.
Supported systems
| Family | Systems | Supported |
|---|---|---|
| RHEL | AlmaLinux, Rocky, Red Hat, Fedora, CentOS with dnf |
Yes |
| Debian | Debian, Ubuntu | No |
The command uses dnf only. On Debian and Ubuntu, the package steps fail, but the script continues and still deletes the files in /etc/audit/rules.d/, so don't run it on those systems.
Notes
- Despite the "real-time" comment in the script, the report is a snapshot of what has been recorded so far, not a live view.
- Logging every program start adds some overhead on busy servers and grows
/var/log/audit/audit.logquickly. - Processes started by services or cron have no logged-in user, so their user ID shows as unset.
- Audit events record the executable and user, which makes this useful for finding what ran during a suspected compromise, but it isn't a replacement for
antivirusorscan.
See also
| Command | Description |
|---|---|
cpu |
Check the top ten CPU-consuming commands or services |
top |
Show the top CPU-consuming processes and their parent command |
scan |
Scan newly modified PHP files for shells and the root password |
antivirus |
Built-in GoAdmio antivirus |
sshtop |
Report top SSH brute-force sources and optionally block them |
status |
Collect the status of every systemd service |