Overview
Linux Malware Detect is an open-source (GPLv2) malware scanner from R-fx Networks. It hunts for the stuff that ends up on web servers: PHP shells, JavaScript injectors, base64-encoded backdoors, IRC bots and other code dropped into user web folders.
Signatures come from the author's network edge intrusion detection data, user submissions and community sources. LMD checks files by hash (MD5 and SHA-256), by HEX patterns, by compound signatures and by YARA rules. It can also hand the job to ClamAV and feed ClamAV its own signatures.
It's one layer of server hardening, not a replacement for it.
The project is alive. Version 2.0.1, a large rewrite of the scan and monitor engines, shipped in April 2026, and the GitHub repository gets regular commits and issue triage. The signature set has its own version number in YYYYMMDDnnnnn form, so you can always see how fresh it is (more on that below).
This guide was tested with LMD 2.0.1 on Ubuntu 24.04 and 26.04 LTS, with notes for AlmaLinux and Rocky Linux at the end.
Installation
LMD isn't in the Ubuntu repositories. You install it from the release tarball with the bundled install.sh. All commands below run as a user with sudo.
Step 1: Install the dependencies
shell
1sudo apt update2sudo apt install -y wget ca-certificates inotify-tools bsdextrautilsinotify-tools is needed for real-time monitoring. bsdextrautils provides the column command, which maldet uses to print the list of scan reports (minimal images don't have it).
Step 2: Download the release and verify the checksum
Download the release from the project's GitHub page over HTTPS and check its SHA-256 before you run anything as root:
shell
1VER=2.0.12wget https://github.com/rfxn/linux-malware-detect/releases/download/v${VER}/maldet-${VER}.tar.gz3echo "26674c72208a4c32ae4ed8770a2b5c036b35c0894a4812450df11c5a53d7d8e5 maldet-${VER}.tar.gz" | sha256sum -c -You should see maldet-2.0.1.tar.gz: OK. If you install a newer release, take its SHA-256 from the releases page: GitHub shows the digest next to each asset.
⚠️ Don't use the old maldetect-current.tar.gz download from the rfxn website. It still serves version 1.6.6, and its published .sha256 file doesn't match the archive.
That archive also contains two files that are not in the project's public source code, internals/cve-2026-41940 and internals/host_meta, plus a hidden block in install.sh. According to issue #498, on cPanel servers the installer runs cve-2026-41940 as root: it kills certain processes, quarantines files and can suspend a cPanel reseller account. host_meta adds a detailed host fingerprint to what LMD already sends to cdn.rfxn.com during signature updates. The report comes from an outside user, the maintainer hadn't answered it when we checked on November 6, 2026, and the purpose of the code isn't confirmed. What is certain: it's undocumented and not in the GitHub source. The GitHub release above doesn't contain these files.
If you installed LMD from the rfxn.com tarball before
Check whether the extra files are on the server:
shell
1ls -l /usr/local/maldetect/internals/cve-2026-41940 /usr/local/maldetect/internals/host_meta /usr/local/maldetect/cve-2026-41940.done2grep -i cve-2026-41940 /usr/local/maldetect/logs/event_log"No such file or directory" for all three files and no match in the event log mean this install didn't come from the affected tarball. If any of them exist:
- Remove LMD with
sudo /usr/local/maldetect/uninstall.shand install it again from the GitHub release as shown above. - If
cve-2026-41940.doneexists, the script has already run. On a cPanel server, check WHM for suspended accounts (whmapi1 listsuspended) and look for files or services that stopped working around the install date. - Turn off automatic version updates (step 4), so the daily cron job doesn't download the same tarball again.
Step 3: Run the installer
shell
1tar -xzf maldet-${VER}.tar.gz2cd maldet-${VER}3sudo ./install.shThe installer copies LMD to /usr/local/maldetect, links the maldet command into /usr/local/sbin, adds cron jobs, installs a systemd unit for the monitor and downloads the first signature set. The end of the output looks like this:
shell
1maldet(476): {sigup} signature set update completed2maldet(476): {sigup} 47,844 signatures (45,385 MD5 | 2,373 HEX | 86 CSIG | 3,706 YARA(no engine) | 0 USER)3
4 Install path: /usr/local/maldetect5 Config file: /usr/local/maldetect/conf.maldet6 Exec file: /usr/local/maldetect/maldet7 Exec link: /usr/local/sbin/maldet8 Exec link: /usr/local/sbin/lmd9 Cron.daily: /etc/cron.daily/maldet10 Linux Malware Detect 2.0.1 installation completeThe main config file is /usr/local/maldetect/conf.maldet. Every option in it is commented.
Step 4: Switch off automatic version updates
By default the daily cron job also tries to update LMD itself (autoupdate_version="1"). In 2.0.1 that check pulls the same maldetect-current.tar.gz from the rfxn CDN. On our test server the update only stopped because the checksum didn't match:
shell
1maldet(9283): {update} version check shows latest but hash check failed, forcing update...2maldet(9283): {update} unable to verify sha256sum of maldetect-current.tar.gz, please try againUntil the vendor sorts this out, turn version updates off and upgrade by hand from GitHub releases. Signature updates stay on:
shell
1sudo sed -i 's/^autoupdate_version="1"/autoupdate_version="0"/' /usr/local/maldetect/conf.maldet2grep -E '^autoupdate_(version|signatures)=' /usr/local/maldetect/conf.maldetUpdate malware signatures
shell
1sudo maldet -uThe installer adds /etc/cron.d/maldet-sigup, which runs the same update every 6 hours, and the daily cron job checks again. Downloads are verified by SHA-256 (you'll see verified sha256sum of maldet-sigpack.tgz in the output).
To see which signature set you have:
shell
1cat /usr/local/maldetect/sigs/maldet.sigs.verThe first eight digits are the release date of the set. If that date is months old, keep it in mind when you read a clean report.
Test detection with EICAR
Before you trust a clean result, make sure the scanner actually finds something. EICAR is a standard, harmless antivirus test file that every scanner detects.
Create a test site with one clean page and one EICAR file, owned by the web server user:
shell
1sudo mkdir -p /var/www/example.com/public2echo '<?php echo "hello from a clean page"; ?>' | sudo tee /var/www/example.com/public/index.php > /dev/null3printf '%s' 'X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*' | sudo tee /var/www/example.com/public/eicar.php > /dev/null4sudo chown -R www-data:www-data /var/www/example.comThe ownership matters. LMD skips files owned by root (user or group) by default (scan_ignore_root="1"), because on a web server the interesting files belong to users and the web server.
A root-owned test file gives you a confusing "empty file list" result. To include root-owned files in one scan, add -co scan_ignore_root=0.
Scan files
Scan a whole directory
shell
1sudo maldet -a /var/www/example.com/publicshell
1maldet(804): {scan} scan completed on /var/www/example.com/public: files 2, malware hits 1, cleaned hits 0, time 4s2maldet(804): {scan} scan report saved, to view run: maldet --report 261102-1322.8043maldet(804): {scan} quarantine is disabled! set quarantine_hits=1 in conf.maldet or to quarantine results run: maldet -q 261102-1322.804Every scan gets an ID (261102-1322.804 here). You'll use it for reports, quarantine and restore.
The ? character works as a wildcard, which is handy for per-user web roots on cPanel-style servers. Several paths go in one argument, separated by commas with no spaces:
shell
1sudo maldet -a /home/?/public_html2sudo maldet -a /var/www/example.com/public,/home/alice/public_htmlThe exit code is 0 when nothing is found, 2 when there are hits and 1 on errors (for example, a path that doesn't exist). That makes maldet easy to wire into your own scripts and monitoring.
Scan only recent changes
-r scans files created or changed in the last N days:
shell
1sudo maldet -r /var/www/example.com/public 2LMD matches on both the modification time and the inode change time. In our test, a file with its mtime pushed 10 days back with touch was still picked up by -r ... 1, so backdating a dropped web shell doesn't hide it from this scan.
Run long scans in the background
Large trees can take hours. Instead of keeping a terminal open, start the scan in the background:
shell
1sudo maldet -b -a /var/wwwProgress goes to /var/log/maldet/event_log. The report shows up in the list when the scan finishes. sudo maldet -L lists running scans, and --pause, --stop and --kill with a scan ID control them.
By default LMD skips files larger than 2 MB and smaller than 24 bytes (scan_max_filesize and scan_min_filesize in the config).
Read scan reports
Show the latest report:
shell
1sudo maldet -eshell
1SCAN ID: 261102-1322.8042PATH: /var/www/example.com/public3RANGE: all4FILES: 25HITS: 16CLEANED: 07QUARANTINED: 0 (quarantine disabled)8BY TYPE: SHA256(1)9
10FILE HIT LIST:11{SHA256}test.test.eicar.29805 : /var/www/example.com/public/eicar.phpThe prefix in curly braces tells you which stage matched: {MD5} or {SHA256} for a hash, {HEX} for a pattern, {CSIG} for a compound signature, {YARA} for a YARA rule and {CAV} for ClamAV.
List all reports, or open a specific one:
shell
1sudo maldet -e list2sudo maldet -e 261102-1322.804For scripts and dashboards, the same report comes out as JSON:
shell
1sudo maldet --json-report 261102-1322.804Quarantine and restore
Quarantine is off by default, so a scan only reports. To move the hits from a scan into quarantine:
shell
1sudo maldet -q 261102-1322.804shell
1maldet(5189): {quar} 1 files quarantined [quarantine]The file disappears from the site and lands in /usr/local/maldetect/quarantine/ with permissions 000. Next to it, a .info file keeps the original path, owner, mode and timestamps.
If it was a false positive, restore everything from that scan, or a single file by its quarantine name:
shell
1sudo maldet -s 261102-1322.8042sudo maldet -s eicar.php.235877The file comes back to the same path with its original owner, permissions and mtime.
To quarantine hits automatically, set it in the config:
shell
1sudo sed -i 's/^quarantine_hits="0"/quarantine_hits="1"/' /usr/local/maldetect/conf.maldetOr only for one run: sudo maldet -co quarantine_hits=1 -a /var/www. Turn it on after a few scans have shown you no false positives on your own code. Moving a file a live site needs will break that site.
Add ClamAV as a scan engine
ClamAV adds its own large signature database on top of LMD's. With ClamAV installed, LMD uses it automatically (scan_clamscan="auto") and links its own signatures into ClamAV's database directory.
shell
1sudo apt install -y clamav clamav-daemon2sudo systemctl enable --now clamav-freshclamWait until freshclam has downloaded the databases. Both main and daily must be there:
shell
1ls /var/lib/clamav/Then start the daemon and let LMD re-link its signatures:
shell
1sudo systemctl enable --now clamav-daemon2sudo maldet -u --forceRun the EICAR scan again. The output should say that the ClamAV engine is used, and the hit should be there:
shell
1maldet(13133): {scan} found clamav binary at /usr/bin/clamdscan, using clamav scanner engine...2maldet(13133): {scan} scan completed on /var/www/example.com/public: files 2, malware hits 1, cleaned hits 0, time 6sWith a running clamd, LMD uses clamdscan, which is much faster than loading the databases for every scan with clamscan. The daemon needs about 1-1.5 GB of RAM.
⚠️ Always repeat the EICAR test after you add ClamAV.
In our test, ClamAV was installed but freshclam hadn't downloaded its databases yet. LMD still switched to the ClamAV engine, ClamAV loaded no signatures, and the scan reported malware hits 0 on the EICAR file without any error on screen.
If ClamAV can't be kept healthy on a server, set scan_clamscan="0" and LMD uses its own engine.
Without ClamAV, LMD's YARA rules show up as YARA(no engine). Installing the yara package (sudo apt install -y yara) turns on LMD's native YARA stage.
The daily cron scan
The installer adds /etc/cron.daily/maldet. Once a day it:
- Removes quarantine, session and temp data older than 21 days (
cron_prune_days). - Updates signatures (and LMD itself, unless you turned that off in Step 4).
- Scans files changed in the last day (
scan_days="1").
The job detects cPanel, Plesk, DirectAdmin, ISPConfig, Virtualmin, HestiaCP and other panels and scans their web roots. On a plain server it scans /home?/?/public_html/, /var/www/ and /usr/local/apache/htdocs/. It also waits a random 1-999 seconds before starting, to spread the load on the update servers.
To add your own paths, append a line to the hook file that the daily job runs:
shell
1echo '/usr/local/sbin/maldet -b -r /srv/app 1 >> /dev/null 2>&1' | sudo tee -a /usr/local/maldetect/cron/custom.cronIf the inotify monitor is running, the daily job skips its scan and sends a daily report of monitor events instead.
Real-time monitoring with inotify
The monitor watches folders through the kernel inotify subsystem and scans every file that is created, changed or moved in, in batches every 15 seconds (inotify_sleep).
What it needs:
- a kernel with
CONFIG_INOTIFY_USER, which every current distribution kernel has; - the
inotifywaitcommand frominotify-tools(installed in Step 1); - enough inotify watches. LMD raises
max_user_watchesandmax_user_instancesitself, one watch per directory. Inside a container these limits belong to the host kernel, so set them on the host.
Step 1: List the folders to watch
One path per line:
shell
1printf '%s\n' /var/www/example.com/public /home/alice/public_html | sudo tee /usr/local/maldetect/monitor_pathsYou can also pass paths straight to maldet -m, separated by commas with no spaces (/var/www,/srv/app). With a space after the comma, the second path is silently dropped. A special mode, users, watches the public_html and public_ftp folders of every user with a UID of 500 or higher, plus /tmp, /var/tmp and /dev/shm.
Step 2: Run the monitor as a systemd service
The installer ships a maldet unit that reads the mode from /etc/default/maldet (on RHEL-family systems, /etc/sysconfig/maldet). The default there is users. Point it at your file:
shell
1sudo sed -i 's|^MONITOR_MODE=.*|MONITOR_MODE="/usr/local/maldetect/monitor_paths"|' /etc/default/maldet2sudo systemctl enable --now maldet3systemctl status maldetshell
1● maldet.service - Linux Malware Detect monitoring - maldet2 Active: active (running) since Mon 2026-11-02 13:32:59 UTC; 15s ago3 ├─14278 bash /usr/local/maldetect/maldet --monitor /usr/local/maldetect/monitor_paths4 ├─14399 /usr/bin/inotifywait -r --fromfile /usr/local/maldetect/sess/.inotify.paths.oDvwwz ...⚠️ Don't use maldet -b -m to start the monitor in the background. In 2.0.1 it starts and exits a second later with existing monitor process detected (it finds its own PID file).
The bug is tracked in issue #505. The systemd service runs the monitor in the foreground and isn't affected.
Step 3: Check that it catches an upload
With quarantine_hits="1", drop an EICAR file into a watched folder as the web server user:
shell
1printf '%s' 'X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*' | sudo -u www-data tee /var/www/example.com/public/upload.php > /dev/null2sleep 303sudo grep -E '\{hit\}|\{quar\}' /var/log/maldet/event_log | tail -2shell
1maldet(14278): {hit} 1 malware hits recorded [clamav]2maldet(14278): {quar} 1 files quarantined [clamav]In our test the file was quarantined 11 seconds after it was written. Raw inotify events are in /var/log/maldet/inotify_log. To stop the monitor, run sudo maldet -k or sudo systemctl stop maldet.
What LMD does not do
LMD is good at one job: finding known malicious files in web folders. Be clear about the rest.
- It's a signature scanner. It finds what is in its signature sets, plus some obfuscation heuristics. New or custom malware, and anything its signatures don't cover yet, gets through. A clean report is not proof of a clean server.
- It's not EDR. It doesn't watch processes, network connections, logins or memory, and it won't stop an attacker who is already running code. Fileless attacks never touch its folders.
- It's not a rootkit scanner for the operating system. It deliberately skips root-owned files by default and focuses on user and web content.
- It doesn't fix the hole. If a web shell appeared, something let it in: an outdated plugin, a weak password, writable code folders. Find and close that, or the file will be back tomorrow.
Use it together with patching, least-privilege file permissions, a hardened /tmp, a web application firewall, centralized logs and, for anything that matters, an EDR agent.
RHEL, AlmaLinux and Rocky Linux
The same steps work with three changes:
shell
1sudo dnf install -y epel-release2sudo dnf install -y wget inotify-tools util-linuxinotify-toolscomes from EPEL.- The monitor service reads
MONITOR_MODEfrom/etc/sysconfig/maldetinstead of/etc/default/maldet. - The web server user is usually
apache(ornginx), notwww-data.
We ran the install, the EICAR scan and the monitor start on AlmaLinux 10 and Rocky Linux 9 with the same results as on Ubuntu.
Remove LMD
shell
1sudo /usr/local/maldetect/uninstall.shIt asks for confirmation and removes LMD, its cron jobs, the systemd unit and all quarantine data.
If you'd rather have someone else watch your servers, our team does security hardening and compliance for cloud and hosting infrastructure.
