{"id":1373,"date":"2026-09-03T11:37:48","date_gmt":"2026-09-03T06:07:48","guid":{"rendered":"https:\/\/cpanelfree.com\/blog\/how-to-scan-linux-server-malware-maldet-clamav\/"},"modified":"2026-09-03T12:32:27","modified_gmt":"2026-09-03T07:02:27","slug":"how-to-scan-linux-server-malware-maldet-clamav","status":"publish","type":"post","link":"https:\/\/cpanelfree.com\/blog\/how-to-scan-linux-server-malware-maldet-clamav\/","title":{"rendered":"How to Scan Linux Server for Malware and Backdoors (ClamAV &amp; Maldet Tutorial)"},"content":{"rendered":"<div style=\"background-color: #f8fafc;border-left: 4px solid #10b981;padding: 20px;border-radius: 6px;margin-bottom: 25px\">\n<p style=\"margin: 0;font-size: 16px;color: #1e293b\">\n        <strong>Quick Answer:<\/strong> To scan a Linux server for malware and backdoors, install <strong>Linux Malware Detect (LMD\/Maldet)<\/strong> paired with the <strong>ClamAV<\/strong> binary scanning engine. Update threat signatures with <code>maldet -u<\/code>, execute a full scan on your web directories with <code>maldet -a \/var\/www\/<\/code>, and inspect quarantined malicious files with <code>maldet --report<\/code>.\n    <\/p>\n<\/div>\n<h2>Common Linux Web Server Threats in 2026<\/h2>\n<p>Compromised WordPress installations, outdated plugins, and vulnerable upload forms frequently result in attacker webshells (like c99, r57, and WSO), obfuscated PHP backdoors, crypto-miners, and hidden cron scripts. Standard antivirus software built for Windows cannot effectively detect PHP-based server malware. Pairing <strong>Linux Malware Detect (LMD)<\/strong> with <strong>ClamAV<\/strong> provides comprehensive dual-layer threat detection designed specifically for hosting environments.<\/p>\n<h2>Step 1: Installing ClamAV Binary Engine<\/h2>\n<p>ClamAV acts as a high-speed scanning backend for Maldet, speeding up scanning throughput by over 10x:<\/p>\n<pre style=\"background-color: #1e293b;color: #38bdf8;padding: 14px;border-radius: 6px;font-size: 13px\"># Install ClamAV daemon and freshclam database updater\nsudo apt update &amp;&amp; sudo apt install clamav clamav-daemon -y\n\n# Update ClamAV virus signatures\nsudo systemctl stop clamav-freshclam\nsudo freshclam\nsudo systemctl start clamav-freshclam<\/pre>\n<h2>Step 2: Installing Linux Malware Detect (Maldet)<\/h2>\n<p>Download and install the latest official Maldet release:<\/p>\n<pre style=\"background-color: #1e293b;color: #38bdf8;padding: 14px;border-radius: 6px;font-size: 13px\">cd \/tmp\ncurl -O https:\/\/www.rfxn.com\/downloads\/maldetect-current.tar.gz\ntar -xzf maldetect-current.tar.gz\ncd maldetect-*\nsudo .\/install.sh<\/pre>\n<h2>Step 3: Configuring Automatic Quarantine &amp; Email Alerts<\/h2>\n<p>Edit <code>\/usr\/local\/maldetect\/conf.maldet<\/code> to enable automated quarantine of malicious payloads:<\/p>\n<pre style=\"background-color: #1e293b;color: #38bdf8;padding: 14px;border-radius: 6px;font-size: 13px\">sudo nano \/usr\/local\/maldetect\/conf.maldet<\/pre>\n<p>Update these directives:<\/p>\n<pre style=\"background-color: #1e293b;color: #38bdf8;padding: 14px;border-radius: 6px;font-size: 13px\"># Enable email alerts\nemail_alert=\"1\"\nemail_addr=\"admin@yourdomain.com\"\n\n# Enable ClamAV as high-speed scanning backend\nscan_clamav=\"1\"\n\n# Automatically quarantine infected files\nquarantine_hits=\"1\"\nquarantine_clean=\"1\"<\/pre>\n<h2>Step 4: Running a Targeted Malware Scan<\/h2>\n<p>Update signatures and scan your web directories:<\/p>\n<pre style=\"background-color: #1e293b;color: #38bdf8;padding: 14px;border-radius: 6px;font-size: 13px\"># Update signatures\nmaldet -u\n\n# Scan all public_html and \/var\/www directories\nmaldet -a \/var\/www\/\nmaldet -a \/home\/*\/public_html\/\n\n# View the latest scan report\nmaldet --report SCAN_ID<\/pre>\n<h2>Setting Up Automated Nightly Malware Scans via Cron<\/h2>\n<p>To ensure your web applications remain clean without manual intervention, configure a system cron job to scan web roots nightly and dispatch email alerts upon detecting suspicious PHP injection patterns:<\/p>\n<pre style=\"background-color: #1e293b;color: #38bdf8;padding: 14px;border-radius: 6px;font-size: 13px\"># Create automated malware scanning cron script\nsudo nano \/etc\/cron.daily\/maldet-nightly-scan\n\n#!\/bin\/bash\n\/usr\/local\/bin\/maldet -u &gt; \/dev\/null 2&gt;&amp;1\n\/usr\/local\/bin\/maldet -a \/var\/www \/home\/*\/public_html &gt;&gt; \/var\/log\/maldet_scan.log 2&gt;&amp;1\n\nsudo chmod +x \/etc\/cron.daily\/maldet-nightly-scan<\/pre>\n<h2>Inspecting Suspicious Cron Jobs and Rogue SSH Keys<\/h2>\n<p>Attackers who compromise a PHP web application frequently establish persistence through hidden user cron jobs and unauthorized SSH keys. Audit system cron directories regularly:<\/p>\n<pre style=\"background-color: #1e293b;color: #38bdf8;padding: 14px;border-radius: 6px;font-size: 13px\"># Check crontabs for all system users\nfor user in $(cut -f1 -d: \/etc\/passwd); do sudo crontab -u $user -l 2&gt;\/dev\/null; done\n\n# Check system cron directories\nls -la \/etc\/cron* \/var\/spool\/cron\/crontabs\/<\/pre>\n<h2>Detailed Analysis of Common Web Server Backdoors and Webshells<\/h2>\n<p>Web server malware operates differently than desktop viruses. Attackers rarely execute destructive commands; instead, they plant subtle, stealthy backdoors to monetize your server resources. Here are the 3 most prevalent threats detected by LMD &amp; ClamAV:<\/p>\n<ul style=\"padding-left: 20px;line-height: 1.8\">\n<li><strong>PHP Webshells (c99, r57, b374k, WSO):<\/strong> Complete web-based file managers injected into <code>wp-content\/uploads\/<\/code> that allow remote attackers to execute terminal commands, dump MySQL databases, and edit core application files through a hidden browser interface.<\/li>\n<li><strong>Malicious SEO Spam &amp; Redirection Injections:<\/strong> Code snippets injected into <code>index.php<\/code> or <code>wp-config.php<\/code> that detect search engine bots (Googlebot) and serve invisible spam links or redirect mobile visitors to fraudulent phishing landing pages.<\/li>\n<li><strong>Crypto-Miners &amp; Botnet Workers (XMRig \/ Mirai):<\/strong> Binary executables placed in <code>\/tmp<\/code> or <code>\/dev\/shm<\/code> that consume 100% of server CPU cores mining cryptocurrency or launching distributed denial of service (DDoS) attacks against third parties.<\/li>\n<\/ul>\n<h2>Hardening PHP Configuration (disable_functions) to Prevent Execution<\/h2>\n<p>In addition to scanning for malware, prevent webshells from executing dangerous system-level commands by adding a robust <code>disable_functions<\/code> directive to your <code>php.ini<\/code> configuration:<\/p>\n<pre style=\"background-color: #1e293b;color: #38bdf8;padding: 14px;border-radius: 6px;font-size: 13px\"># \/etc\/php\/8.3\/fpm\/php.ini\ndisable_functions = exec,passthru,shell_exec,system,proc_open,popen,curl_multi_exec,parse_ini_file,show_source<\/pre>\n<h2>Automated ClamAV Daemon Inotify Real-Time Filesystem Monitoring<\/h2>\n<p>Rather than relying solely on nightly cron scans, you can configure <code>clamd<\/code> with Linux kernel inotify filesystem watches (using <code>clamonacc<\/code>). This enables continuous real-time protection that automatically scans every new file uploaded via PHP, FTP, or SSH the millisecond it is written to disk:<\/p>\n<pre style=\"background-color: #1e293b;color: #38bdf8;padding: 14px;border-radius: 6px;font-size: 13px\"># Enable real-time on-access scanning in clamd.conf\nsudo nano \/etc\/clamav\/clamd.conf\n\n# Add directives:\nOnAccessMaxFileSize 20M\nOnAccessIncludePath \/var\/www\nOnAccessPrevention yes\n\n# Start real-time on-access daemon\nsudo systemctl enable --now clamav-clamonacc<\/pre>\n<h2>Recovering and Cleaning a Hacked WordPress Database<\/h2>\n<p>Malware frequently injects malicious JavaScript redirects and rogue administrator users directly into the MySQL database (specifically the <code>wp_options<\/code> and <code>wp_users<\/code> tables). After scanning files, audit your WordPress database:<\/p>\n<pre style=\"background-color: #1e293b;color: #38bdf8;padding: 14px;border-radius: 6px;font-size: 13px\"># Check for unauthorized administrator users in database\nwp user list --role=administrator --allow-root\n\n# Scan core WordPress files against official checksums\nwp core verify-checksums --allow-root\nwp plugin verify-checksums --all --allow-root<\/pre>\n<h2>Integrating ClamAV with Nextcloud &amp; Web Upload Gateways<\/h2>\n<p>If your Linux VPS hosts cloud storage portals like Nextcloud or custom web applications accepting user file uploads, configure ClamAV Daemon sockets directly within your web application settings. This ensures every uploaded PDF, image, or ZIP archive is scanned in memory before being committed to persistent NVMe disk storage, preventing malicious payload distribution.<\/p>\n<div style=\"background-color: #f8fafc;border: 1px solid #e2e8f0;border-left: 4px solid #0ea5e9;padding: 20px;border-radius: 8px;margin: 30px 0\">\n<h3 style=\"margin-top: 0;color: #0f172a;font-size: 18px;display: flex;align-items: center\">\n        <span style=\"margin-right: 8px\">\ud83d\udd17<\/span> Recommended Related Technical Guides:<br \/>\n    <\/h3>\n<ul style=\"margin: 10px 0 0 0;padding-left: 20px;line-height: 1.8\">\n<li><a href=\"https:\/\/cpanelfree.com\/blog\/how-to-configure-ufw-firewall-ubuntu\/\" style=\"color: #0284c7;text-decoration: none;font-weight: 600\">How to Configure UFW Firewall on Ubuntu Server<\/a><\/li>\n<li><a href=\"https:\/\/cpanelfree.com\/blog\/how-to-install-configure-fail2ban-linux\/\" style=\"color: #0284c7;text-decoration: none;font-weight: 600\">How to Install and Configure Fail2ban on Linux<\/a><\/li>\n<li><a href=\"https:\/\/cpanelfree.com\/blog\/how-to-change-ssh-port-linux-vps\/\" style=\"color: #0284c7;text-decoration: none;font-weight: 600\">How to Change Default SSH Port on Linux VPS<\/a><\/li>\n<li><a href=\"https:\/\/cpanelfree.com\/blog\/best-free-web-hosting-2026\/\" style=\"color: #0284c7;text-decoration: none;font-weight: 600\">Top 10 Best Free Web Hosting Services<\/a><\/li>\n<li><a href=\"https:\/\/cpanelfree.com\/#plans\" style=\"color: #0284c7;text-decoration: none;font-weight: 600\">Explore $0 Free cPanel Web Hosting Plans<\/a><\/li>\n<\/ul>\n<\/div>\n<div style=\"background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);border: 1px solid #334155;border-radius: 12px;padding: 25px;margin: 30px 0;text-align: center\">\n<h3 style=\"color: #38bdf8;margin-top: 0;font-size: 20px\">Automated Malware Immunity on CpanelFree<\/h3>\n<p style=\"color: #94a3b8;font-size: 14px;line-height: 1.6;max-width: 600px;margin: 0 auto 15px\">\n        Never worry about infected files or webshells. <strong>CpanelFree<\/strong> includes 24\/7 automated real-time malware scanners, CageFS isolation, and instant threat neutralization at $0 cost.\n    <\/p>\n<p>    <a href=\"https:\/\/cpanelfree.com\/free-wordpress-hosting\" style=\"display: inline-block;background-color: #10b981;color: #ffffff;padding: 10px 22px;border-radius: 6px;text-decoration: none;font-weight: bold;font-size: 14px\">Deploy Free WordPress Site<\/a>\n<\/div>\n<h2>Frequently Asked Questions<\/h2>\n<div style=\"border-bottom: 1px solid #e2e8f0;padding: 12px 0\">\n<h4 style=\"margin: 0 0 8px 0;color: #1e293b\">How can I restore a false-positive file from quarantine?<\/h4>\n<p style=\"margin: 0;color: #475569;font-size: 14px\">Run <code>maldet --restore FILENAME<\/code> or restore by scan ID with <code>maldet --restore \/usr\/local\/maldetect\/quarantine\/FILENAME.ID<\/code>.<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Quick Answer: To scan a Linux server for malware and backdoors, install Linux Malware Detect (LMD\/Maldet) paired with the ClamAV binary scanning engine. Update threat signatures with maldet -u, execute a full scan on your web directories with maldet -a \/var\/www\/, and inspect quarantined malicious files with maldet &#8211;report. Common Linux Web Server Threats in [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1372,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[64],"tags":[],"class_list":["post-1373","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-security"],"_links":{"self":[{"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/posts\/1373","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/comments?post=1373"}],"version-history":[{"count":5,"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/posts\/1373\/revisions"}],"predecessor-version":[{"id":1561,"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/posts\/1373\/revisions\/1561"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/media\/1372"}],"wp:attachment":[{"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/media?parent=1373"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/categories?post=1373"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/tags?post=1373"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}