{"id":2398,"date":"2015-11-05T14:36:09","date_gmt":"2015-11-05T12:36:09","guid":{"rendered":"https:\/\/upcloud.com\/global\/us\/resources\/tutorials\/scan-debian-server-malware\/"},"modified":"2026-04-23T14:27:25","modified_gmt":"2026-04-23T13:27:25","slug":"scan-debian-server-malware","status":"publish","type":"tutorial","link":"https:\/\/upcloud.com\/global\/resources\/tutorials\/scan-debian-server-malware\/","title":{"rendered":"How to scan Debian server for malware"},"content":{"rendered":"\n<p>Some unexpected behaviour on a <a href=\"https:\/\/upcloud.com\/global\/resources\/tutorials\/secure-linux-cloud-server\/\">Linux server<\/a> could be a result of malware\u00a0infection, while other malicious software might not alert to their presence. Scanning your system for different types of unwanted programs can help identify issues, or at least give you peace of mind for having a clean server.<\/p>\n\n\n\n<p>There are multiple&nbsp;options for making sure your cloud server is clean of any&nbsp;malware, this guide&nbsp;goes over&nbsp;a couple of scanning software you can utilise for checking your system.<\/p>\n\n\n\n<div class=\"wp-block-buttons is-layout-flex wp-block-buttons-is-layout-flex\">\n<div class=\"wp-block-button\"><a class=\"wp-block-button__link wp-element-button\" href=\"https:\/\/signup.upcloud.com\/\">Test hosting on UpCloud!<\/a><\/div>\n<\/div>\n\n\n\n<h2 class=\"wp-block-heading\">ClamAV<\/h2>\n\n\n\n<p>ClamAV is a popular open-source antivirus engine available on a multitude of platforms including the majority of Linux distributions. Install it on your Debian system with the command below.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo aptitude install clamav clamav-daemon<\/pre>\n\n\n\n<p>With the required modules installed, next, you should update the virus database for ClamAV.<\/p>\n\n\n\n<p>First, stop the related processes to allow for the update the proceed.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo systemctl stop clamav-freshclam<\/pre>\n\n\n\n<p>Then use the command below to run the updater application.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo freshclam<\/pre>\n\n\n\n<p>When you\u2019ve finished updating the virus definitions, start and enable the services.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo systemctl start clamav-freshclam\nsudo systemctl enable clamav-freshclam<\/pre>\n\n\n\n<p>Then do a test scan to your home directory just to make sure the scanning works as it should use the following command.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo clamscan -r \/home<\/pre>\n\n\n\n<p>Granted that your home directory didn\u2019t contain any viruses or other types of malware, the scan should come back empty.<\/p>\n\n\n\n<p>So how do you know it works?<\/p>\n\n\n\n<p>For this, you can download an anti-virus test file, which is a small completely harmless program that most anti-virus software report as infected, though with an obvious test file name EICAR-AV-Test. Use the following command to download the test file to your home directory.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">wget -P ~\/ http:\/\/www.eicar.org\/download\/eicar.com<\/pre>\n\n\n\n<p>Now scan your home folder again with the same command as above, you should receive notice of one infected file at the end summary after the scan is completed. When you\u2019ve confirmed that ClamAV finds the test file correctly, use the command below to scan it again and remove the infected file once found.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo clamscan --infected --remove --recursive \/home<\/pre>\n\n\n\n<p>Be careful when using the <em>\u2013remove<\/em> parameter. First, run a broader scan without it, and then a more localized scan when removing files or removing them manually.<\/p>\n\n\n\n<p>To perform a complete scan of your cloud server, use this command.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo clamscan --infected --recursive --exclude-dir=\"^\/sys\" \/<\/pre>\n\n\n\n<p>The scan goes through each directory in your system root recursively, but skips <em>\/sys<\/em> just to avoid unnecessary&nbsp;warning printouts, as the virtual file system consists of some unreadable files, which could not contain viruses anyway.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Rkhunter<\/h2>\n\n\n\n<p>Rkhunter is a&nbsp;common option for scanning your system for rootkits and general vulnerabilities. It can be easily installed using&nbsp;the package manager on Debian systems.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo aptitude install rkhunter<\/pre>\n\n\n\n<p>Once installed and before scanning, you\u2019ll need to update the file properties database.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo rkhunter --propupd<\/pre>\n\n\n\n<p>This lets the scanner know the current state of certain files to prevent some false alarms. After the update, simply run the scanner with the following.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo rkhunter --checkall<\/pre>\n\n\n\n<p>The scanner goes through some system commands, checks for actual rootkits and some malware, network and local host settings, and then give you the summary as well as records the findings to a log file.<\/p>\n\n\n\n<p>Afterwards, you can get a condensed look at the scan log with this command.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo cat \/var\/log\/rkhunter.log | grep -i warning<\/pre>\n\n\n\n<p>Go through the output to get some tips on what you could do to improve your system security.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Chkrootkit<\/h2>\n\n\n\n<p>Chkrootkit is a popular rootkit scanner, which&nbsp;runs a lot of useful checks and can direct suspicions towards finding a solution. It can be installed on most distributions with the package manager, on a Debian server&nbsp;using the following.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo aptitude install chkrootkit<\/pre>\n\n\n\n<p>Once done, scan your server with this command.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo chkrootkit<\/pre>\n\n\n\n<p>The scan will check for many types of infections and print out its findings. You can scroll through the output to check for any warnings.<\/p>\n\n\n\n<p>Chkrootkit doesn\u2019t write reports other than outputting to the screen by default, but if you wish to automate the checks or to take a look at the findings later, use the <em>tee<\/em> command to redirect the printout&nbsp;to a log file.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo chkrootkit | sudo tee \/var\/log\/chkrootkit\/chkrootkit.log<\/pre>\n\n\n\n<p>You can then easily check the log for any warnings.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo cat \/var\/log\/chkrootkit\/chkrootkit.log | grep -i warning<\/pre>\n\n\n\n<p>While&nbsp;the option can be used to help determine if a machine has been compromised, it&nbsp;shouldn\u2019t be taken&nbsp;as the \u2018final word\u2019, use it together&nbsp;with other scanners to diagnose any possible infections.<\/p>\n","protected":false},"author":3,"featured_media":27370,"comment_status":"open","ping_status":"closed","template":"","community-category":[253,289],"class_list":["post-2398","tutorial","type-tutorial","status-publish","has-post-thumbnail","hentry"],"acf":[],"_links":{"self":[{"href":"https:\/\/upcloud.com\/global\/wp-json\/wp\/v2\/tutorial\/2398","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/upcloud.com\/global\/wp-json\/wp\/v2\/tutorial"}],"about":[{"href":"https:\/\/upcloud.com\/global\/wp-json\/wp\/v2\/types\/tutorial"}],"author":[{"embeddable":true,"href":"https:\/\/upcloud.com\/global\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/upcloud.com\/global\/wp-json\/wp\/v2\/comments?post=2398"}],"version-history":[{"count":1,"href":"https:\/\/upcloud.com\/global\/wp-json\/wp\/v2\/tutorial\/2398\/revisions"}],"predecessor-version":[{"id":6465,"href":"https:\/\/upcloud.com\/global\/wp-json\/wp\/v2\/tutorial\/2398\/revisions\/6465"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/upcloud.com\/global\/wp-json\/"}],"wp:attachment":[{"href":"https:\/\/upcloud.com\/global\/wp-json\/wp\/v2\/media?parent=2398"}],"wp:term":[{"taxonomy":"community-category","embeddable":true,"href":"https:\/\/upcloud.com\/global\/wp-json\/wp\/v2\/community-category?post=2398"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}