scanrootkit

rkhunter (Rootkit Hunter) on Linux, Install, Run and Read the Warnings

rkhunter, short for Rootkit Hunter, is a free command-line scanner for Linux and other Unix-like systems. It is a shell script, released under the GPL, that looks for signs of a rootkit in three main ways:

It is not antivirus, and it does not remove anything. It tells you where to look.

Current status

Item Detail
Latest upstream release 1.4.6, 24 February 2018 (SourceForge)
Debian 1.4.6-13 in Debian 13 (trixie), 1.4.6-11 in Debian 12
Fedora 1.4.6
Arch Linux 1.4.6 in the extra repository
macOS 1.4.6 via Homebrew

The project has been quiet upstream since 2018. Distributions continue to patch and ship it, which keeps it working, but its list of named rootkits has not grown. Its property checks are what make it useful today: they catch a modified ls or sshd whatever the rootkit is called.

Install rkhunter

Debian and Ubuntu:

sudo apt update
sudo apt install rkhunter

Fedora:

sudo dnf install rkhunter

On Red Hat Enterprise Linux and its rebuilds, rkhunter comes from the EPEL repository.

Arch Linux:

sudo pacman -S rkhunter

macOS with Homebrew:

brew install rkhunter

Prefer the distribution package over the SourceForge tarball. The package installs config files in the right places and gets security patches.

The three commands that matter

1. Update the data files

sudo rkhunter --update

This checks for newer versions of rkhunter’s data files. An exit code of 2 means updates were installed, which is normal.

On Debian and Ubuntu this usually fails. Debian’s package deliberately disables remote updates: its patch sets WEB_CMD=/bin/false, UPDATE_MIRRORS=0 and MIRRORS_MODE=1 in /etc/rkhunter.conf. The intent is that data files come only from signed packages. You can either accept that and rely on apt upgrade, or re-enable remote updates by adding the upstream defaults to /etc/rkhunter.conf.local:

UPDATE_MIRRORS=1
MIRRORS_MODE=0
WEB_CMD=""

Then run sudo rkhunter -C (--config-check) to confirm the configuration parses.

2. Take the baseline

sudo rkhunter --propupd

This stores the current properties of the files rkhunter watches, in /var/lib/rkhunter/db/rkhunter.dat on Debian. Run it only when you trust the system, ideally straight after installing the OS and rkhunter. A baseline taken on an infected machine records the infected files as normal.

Every time a package update replaces a watched binary, rkhunter will warn about it until you run --propupd again. On Debian you can automate this with sudo dpkg-reconfigure rkhunter, which sets APT_AUTOGEN so the database refreshes after each package install. Debian’s own documentation warns that this opens a small window where an attacker could replace a file after it is installed and before the baseline is refreshed, so on a high-value server you may prefer to run it by hand after checking the update.

3. Run the check

sudo rkhunter --check --sk

--check (or -c) runs the tests. --sk (--skip-keypress) stops it pausing between sections. Add --rwo (--report-warnings-only) to see only warnings.

Reading the results

Everything goes to /var/log/rkhunter.log. The screen output is a summary; the log explains why each warning was raised.

sudo grep -A5 Warning /var/log/rkhunter.log

Work through each warning and ask whether there is an ordinary explanation.

Warning Common harmless cause When to worry
File properties have changed A package update replaced the binary No recent update, or the package manager says the file does not match (dpkg --verify or rpm -Va)
Hidden file or directory found /etc/.java, /dev/.udev, or .hmac checksum files left by FIPS tools An unfamiliar hidden file in /dev, /usr/bin or /lib
Root login allowed via SSH Your SSH config permits it Treat it as a hardening task regardless
Packet-capture application found dhclient, dhcpcd or tcpdump An unknown process with a raw socket
Possible rootkit string The hdparm string in an init script can match the Xzibit rootkit check An actual file named in a rootkit’s file list

Debian’s README for the package lists known false positives, including the hdparm match, the sashroot UID 0 account when sash is installed, IRC daemons on port 6667, and the udev and Java hidden directories.

Once you have confirmed a warning is harmless, whitelist it in /etc/rkhunter.conf.local rather than ignoring it every day. The relevant options include ALLOWHIDDENFILE, ALLOWHIDDENDIR, ALLOWPROCLISTEN, SCRIPTWHITELIST, PORT_WHITELIST, RTKT_FILE_WHITELIST and UID0_ACCOUNTS. Each is documented in comments in /etc/rkhunter.conf.

The cross-check that matters most is the package manager. If rkhunter says /usr/bin/ps changed and dpkg --verify procps (Debian) or rpm -V procps-ng (Fedora) also reports a mismatch with no update to explain it, take it seriously.

Scheduling and email

Debian and Ubuntu ship cron jobs that read /etc/default/rkhunter. The settings to check are:

Set them to "true" as needed, or run sudo dpkg-reconfigure rkhunter. Mail to root only reaches you if the server has a working mail transport and an alias for root.

Other distributions: use --cronjob, which is a non-interactive --check with colours and keypresses turned off, from cron or a systemd timer. For example, in root’s crontab:

30 3 * * * /usr/bin/rkhunter --cronjob --report-warnings-only

You can also set MAIL-ON-WARNING in rkhunter.conf to an email address.

If you run Linux at home on a NAS or a small server, a nightly rkhunter report is a cheap way to notice tampering early. Our sister site has a walkthrough on installing Home Assistant on a Synology NAS, the kind of always-on home box that is worth keeping an eye on.

rkhunter on Windows

There is no Windows version of rkhunter and never has been. It is a Bourne shell script that depends on Unix tools and file layouts. Running it inside WSL only checks the WSL Linux environment, not Windows itself.

On Windows, the equivalent tools are:

The best rootkit scanners compares them, and Windows rootkit detection explains what to look for.

rkhunter, chkrootkit and Lynis

rkhunter and chkrootkit overlap but use different tests, so running both is common practice. Lynis audits configuration rather than looking for rootkits. All three run from inside the system they are checking, so a kernel-level rootkit can hide from them. For a stronger check, boot a trusted live USB, mount the suspect disk read-only and scan it from there, as described in Linux rootkit detection.

If you do find a real compromise, rebuild the machine from known-good media. How to remove a rootkit explains why cleaning in place is not enough after an attacker has had root, and backdoors covers what an intruder usually leaves behind.

Frequently asked questions

What is Rootkit Hunter?
Rootkit Hunter, or rkhunter, is a free, open-source shell script for Unix-like systems that checks for known rootkit files, changed system binaries, hidden files and risky settings. It runs on Linux, the BSDs and macOS.
Is rkhunter still maintained?
The last upstream release is 1.4.6 from 24 February 2018. Debian, Ubuntu, Fedora, Arch and Homebrew still package it, and distributions carry their own patches, but its rootkit signatures are old.
Is there an rkhunter for Windows?
No. rkhunter is a Unix shell script and has never had a Windows version. On Windows, use the Microsoft Defender Offline scan, and Malwarebytes, ESET Online Scanner or HitmanPro for a second opinion.
Why does rkhunter --update fail on Debian or Ubuntu?
Debian's package disables remote updates by setting WEB_CMD to /bin/false and changing the mirror options in rkhunter.conf. Updated data arrives through package updates instead, or you can re-enable remote updates in /etc/rkhunter.conf.local.
Does an rkhunter warning mean I have a rootkit?
Usually not. Most warnings are caused by package updates that changed a file after the baseline was taken, or by normal settings such as hidden directories under /etc. Check each warning in /var/log/rkhunter.log before acting.