GoAdmio

clamav

Install or update ClamAV, or scan hosted domains for malware and delete infected files

On this page: Overview · Quick start · Syntax · Arguments · Output · Examples · Troubleshooting · Details · See also


Overview

/go/clamav manages the open-source ClamAV antivirus engine on a GoAdmio server and uses it to scan hosted sites. It does one of two things, depending on whether you pass an argument:


Quick start

# Install ClamAV, or update its signatures if already installed
/go/clamav

# Scan one domain
/go/clamav example.com

# Scan every account
/go/clamav all

[!WARNING] Scans run with --remove. Infected files are deleted immediately, with no quarantine and no confirmation. Make sure you have a recent backup or snapshot before scanning.


Syntax

# Install ClamAV or update its signatures
/go/clamav

# Scan a single domain
/go/clamav <domain>

# Scan all domains
/go/clamav all
Form Behavior
/go/clamav Installs ClamAV if it is missing; otherwise updates the signatures with freshclam.
/go/clamav <domain> Scans /home/<domain> recursively and deletes infected files.
/go/clamav all Scans everything under /home recursively and deletes infected files.

Only the first argument is used. Extra arguments are ignored.


Arguments

Argument Required Default Notes
<domain> No — The account's domain. /home/<domain> must exist.
all No — Reserved word. Scans every account under /home.

There are no -- options. Giving any argument switches the command into scan mode, so installing and updating happen only when you run it with no argument.

The domain is passed to the scanner as typed. It is not lowercased, normalized, or checked against the Site table, so use the exact folder name from /home.


Output

The command prints plain text, not JSON.

Situation What you see
Install Installing ClamAV antivirus..., followed by the package manager output.
Update Updating ClamAV antivirus..., followed by freshclam output (none on RHEL-family systems, which run it quietly).
Scan one domain Scanning <domain>..., then the list of infected files and a scan summary.
Scan all domains Scanning All Domains..., then the list of infected files and a scan summary.
Unsupported operating system Unknown operating system. Nothing is installed or scanned.
Domain folder not found No output. Nothing is scanned.

Every run is also logged with a timestamp, for example [Nov 20 09:15:02]# clamav example.com, to /var/log/go/clamav.log.

Scans use --infected, so only infected files are listed. Clean files are not printed. The summary at the end of a scan reports the number of files scanned, the number infected, and the data scanned.


Examples

# First run on a new server: installs ClamAV
/go/clamav
# Refresh virus signatures before a scan
/go/clamav
/go/clamav all
# Scan and clean a single account
/go/clamav example.com
# Review what has been run recently
tail -n 20 /var/log/go/clamav.log
# Update signatures daily at 03:00, then scan all accounts at 03:30
0 3 * * *  /go/clamav
30 3 * * * /go/clamav all

Troubleshooting

Symptom Likely cause Fix
Unknown operating system. The OS in /usr/local/goadmio/linux/os.db isn't supported. Supported: AlmaLinux, Rocky, CentOS, Red Hat, Fedora, Debian, Ubuntu.
/go/clamav <domain> prints nothing /home/<domain> doesn't exist. Check the folder name with ls /home, and pass the exact name.
Install runs again on every no-argument run clamconf --version doesn't report ClamAV. Run clamconf --version manually and check that the package installed correctly.
clamscan: command not found ClamAV isn't installed yet. Run /go/clamav with no argument first.
freshclam reports that the log or database is locked A freshclam daemon or another update is already running. Wait for it to finish, then run again.
Scan shows Can't open file or directory A file was removed during the scan, or permissions block access. Run as root, and re-run after site activity settles.
A legitimate file was deleted It was a false positive. Restore it from a backup with restore or snapshot.

Details

How it works

flowchart TD
    A["clamav ..."] --> L["Append the call to /var/log/go/clamav.log"]
    L --> B{"Any argument?"}
    B -- "No" --> C{"Supported OS?"}
    C -- "No" --> X1["Unknown operating system, exit"]
    C -- "Yes" --> D{"ClamAV installed?"}
    D -- "Yes" --> U["Update signatures with freshclam"]
    D -- "No" --> I["Install ClamAV packages"]
    B -- "Yes" --> E{"Argument is 'all'?"}
    E -- "Yes" --> S1["Scan /home, delete infected files"]
    E -- "No" --> F{"/home/domain exists?"}
    F -- "Yes" --> S2["Scan /home/domain, delete infected files"]
    F -- "No" --> X2["Exit, nothing scanned"]

Supported operating systems

Family Systems Install Update
RHEL AlmaLinux, Rocky, CentOS, Red Hat, Fedora yum: clamav, clamav-server, clamav-data, clamav-update, clamav-filesystem, clamav-scanner-systemd, clamav-devel, clamav-lib, clamav-server-systemd freshclam --quiet
Debian Debian, Ubuntu apt: clamav, clamav-daemon freshclam

The OS is read from /usr/local/goadmio/linux/os.db.

Install or update detection

With no argument, the command runs clamconf --version and checks the output for the word "antivirus" (case-insensitive). If found, ClamAV is treated as installed and signatures are updated. Otherwise the packages are installed.

Installing does not run freshclam. Run /go/clamav a second time to download the signature database.

Scan behavior

Setting Effect
--recursive Scans every subfolder.
--infected Prints only infected files.
--remove Deletes infected files permanently.

The scan covers all files in the account folder, including www, mail, and logs, not just website files. Large accounts and all can take a long time and use significant CPU and disk I/O, so schedule them for off-peak hours.

The command doesn't set an exit code of its own. It exits 0 after Unknown operating system., so don't rely on the exit status in scripts.

Notes


See also

Command Description
antivirus Built-in GoAdmio antivirus
scan Scan newly modified PHP files for shells and the root password
backup Create a backup for all GoAdmio accounts (local and remote)
snapshot Restic-based per-domain snapshot backup and restore
restore Restore a GoAdmio backup from the command line
cron Set up main cron jobs in GoAdmio