We'll begin by installing ClamAV. (It's in the normal repository for Ubuntu, but not for CentOS. For CentOS, you'll need to install the EPEL repository, as I showed you how to do in Chapter 1, Running Linux in a Virtual Environment.) We'll also install Wget, which we'll use to download LMD.
The following command will help you install ClamAV and Wget on Ubuntu:
donnie@ubuntu3:~$ sudo apt install clamav wget
The following command will help you install ClamAV and Wget on CentOS:
[donnie@localhost ~]$ sudo yum install clamav clamav-update wget
For Ubuntu, the clamav package contains everything you need. For CentOS, you'll need to also install clamav-update in order to obtain virus updates.
The rest of the steps will be the same for either virtual machine.
Next, you'll download and install LMD. Here, you'll want to do something that I rarely tell people to do. That is, you'll want to log in to the root user shell. The reason is that although the LMD installer works fine with sudo, you'll end up with the program files being owned by the user who performed the installation, instead of by the root user. Performing the installation from the root user's shell saves us the trouble of tracking down those files and changing ownership. So, download the file as follows:
sudo su -
wget http://www.rfxn.com/downloads/maldetect-current.tar.gz
You'll now have the file in the root user's home directory. Now, extract the archive, enter the resultant directory, and run the installer. Once the installer finishes, copy the README file to your own home directory so that you can have it for ready reference. (This README file is the documentation for LMD.) Then, exit from the root user's shell back to your own shell:
tar xzvf maldetect-current.tar.gz
cd maldetect-1.6.2/
root@ubuntu3:~/maldetect-1.6.2# ./install.sh
Created symlink from /etc/systemd/system/multi-user.target.wants/maldet.service to /usr/lib/systemd/system/maldet.service.
update-rc.d: error: initscript does not exist: /etc/init.d/maldet
Linux Malware Detect v1.6
(C) 2002-2017, R-fx Networks <proj@r-fx.org>
(C) 2017, Ryan MacDonald <ryan@r-fx.org>
This program may be freely redistributed under the terms of the GNU GPL
installation completed to /usr/local/maldetect
config file: /usr/local/maldetect/conf.maldet
exec file: /usr/local/maldetect/maldet
exec link: /usr/local/sbin/maldet
exec link: /usr/local/sbin/lmd
cron.daily: /etc/cron.daily/maldet
maldet(22138): {sigup} performing signature update check...
maldet(22138): {sigup} local signature set is version 2017070716978
maldet(22138): {sigup} new signature set (201708255569) available
maldet(22138): {sigup} downloading https://cdn.rfxn.com/downloads/maldet-sigpack.tgz
maldet(22138): {sigup} downloading https://cdn.rfxn.com/downloads/maldet-cleanv2.tgz
maldet(22138): {sigup} verified md5sum of maldet-sigpack.tgz
maldet(22138): {sigup} unpacked and installed maldet-sigpack.tgz
maldet(22138): {sigup} verified md5sum of maldet-clean.tgz
maldet(22138): {sigup} unpacked and installed maldet-clean.tgz
maldet(22138): {sigup} signature set update completed
maldet(22138): {sigup} 15218 signatures (12485 MD5 | 1954 HEX | 779 YARA | 0 USER)
root@ubuntu3:~/maldetect-1.6.2# cp README /home/donnie
root@ubuntu3:~/maldetect-1.6.2# exit
logout
donnie@ubuntu3:~$
As you can see, the installer automatically creates the symbolic link that enables the maldet service, and it also automatically downloads and installs the newest malware signatures.