scanrootkit

Linux Rootkit Detection with rkhunter, chkrootkit and Integrity Checks

Linux has no single built-in rootkit scanner, but it has something more useful: package managers that know the exact checksum of every file they installed, and a set of free tools that look for known rootkits and suspicious changes. This guide covers how to use them, what their results mean, and where their limits are.

The methods behind these tools, cross-view comparison and integrity checking, are explained in how to detect a rootkit.

A warning before you start

Every command below runs on the system you are checking. If a kernel-level rootkit is present, it can lie to these tools. A clean result from inside a running system is weak evidence. The strongest Linux check is to boot from trusted live media, mount the suspect disk read-only, and inspect it from there.

All commands need root, so prefix them with sudo or run them from a root shell.

Why Linux rootkits target ELF files

Almost everything a Linux rootkit tampers with is an ELF file. ELF, the Executable and Linkable Format, is the standard binary format on Linux. The Linux manual describes it as covering “normal executable files, relocatable object files, core files, and shared objects.” Kernel modules (.ko files) are ELF objects too.

That gives a rootkit three main targets:

Target Example How it hides things
Executables Replaced ps, ls, netstat, ss The trojaned tool simply leaves out the attacker’s entries. This is the oldest kind of rootkit.
Shared libraries A malicious .so loaded through /etc/ld.so.preload Every program that uses the hooked functions gets filtered results
Kernel modules A loadable .ko module Edits the kernel’s own answers, so every tool is affected

The preload route is worth understanding. According to the ld.so manual, /etc/ld.so.preload lists shared objects to load before any others, with “a system-wide effect, causing the specified libraries to be preloaded for all programs that are executed on the system.” On most systems that file does not exist or is empty, so checking it is a quick test:

cat /etc/ld.so.preload

If it exists and names a library you cannot account for, investigate. Because trojaned binaries and libraries are ELF files with known-good versions in your distribution’s packages, package verification (below) is the most direct way to catch them.

Step 1: verify installed packages

Your package manager recorded a checksum for every file it installed. Comparing the files on disk against that record shows what has changed.

Debian and Ubuntu, with the debsums package:

sudo apt install debsums
sudo debsums -s

-s reports only errors. Use -c to list just the changed files. Configuration files are excluded by default, which is usually what you want, since you are expected to edit those.

Fedora, RHEL, Rocky, Alma and openSUSE, built into rpm:

sudo rpm -Va

Each line of output is a file that failed one or more tests. The nine characters at the start show which:

Character Meaning
S File size differs
M Mode (permissions or file type) differs
5 Digest (checksum) differs
L Symlink target differs
U / G Owner or group differs
T Modification time differs
. Test passed

A c before the filename marks a configuration file, where changes are normal. A 5 on a binary in /bin, /usr/bin, /sbin or a library under /lib is the result to take seriously.

The limitation: the checksum database lives on the same system. The debsums manual itself says it “is of limited use as a security tool” for that reason. An attacker with root can edit the database too. It still catches a great deal of real-world tampering, and it is quick.

Step 2: run rkhunter

Rootkit Hunter checks for known rootkit files, suspicious file properties, hidden files, wrong permissions on key binaries and some network and startup settings.

Status: the last upstream release is 1.4.6, from February 2018. Debian, Ubuntu, Fedora and others still package it with their own patches, so it runs on current systems, but its list of named rootkits is not being refreshed upstream.

sudo apt install rkhunter        # Debian/Ubuntu
sudo dnf install rkhunter        # Fedora/RHEL (EPEL on RHEL)

sudo rkhunter --update           # refresh data files
sudo rkhunter --propupd          # record current file properties as the baseline
sudo rkhunter --check --sk --rwo

--sk skips the “press Enter” prompts, and --rwo shows only warnings. The full log is written to /var/log/rkhunter.log on a default install.

Run --propupd only on a system you believe is clean, ideally right after installation. Running it on a compromised system records the attacker’s files as normal. After legitimate package updates, rkhunter will warn about changed binaries until you update the baseline again.

More on configuration and whitelisting is on the rkhunter page.

Step 3: run chkrootkit

chkrootkit is a shell script plus small helper programs that check system binaries for known modifications, look for signs of loadable kernel module trojans, detect network interfaces in promiscuous mode and check login records for deletions. Unlike rkhunter, it is still updated: the project site lists version 0.60, released in October 2026.

sudo apt install chkrootkit      # Debian/Ubuntu
sudo chkrootkit -q

-q shows only results flagged as infected. To check a disk mounted from a suspect system while booted from live media:

sudo chkrootkit -r /mnt

The project’s README notes that some tests are skipped with -r, and that its login record checks may not catch every modification. See the chkrootkit page for test details.

Step 4: audit the system with Lynis

Lynis is a free, open-source (GPL) security auditing tool. It is not a rootkit scanner. It reviews the system’s configuration and hardening, and it reports whether a rootkit scanner such as rkhunter or chkrootkit is installed. Its author describes the difference plainly: rkhunter focuses on malware detection, Lynis on security assessment.

sudo apt install lynis
sudo lynis audit system

Use it to find the weak settings that let an attacker in, alongside the scanners that look for what they left behind.

Step 5: file integrity monitoring with AIDE

AIDE (Advanced Intrusion Detection Environment) works like a stricter, configurable version of package verification. It records hashes and attributes of the files you choose, then reports any change. Tripwire is an older tool built on the same idea.

On Fedora and RHEL, Red Hat’s documented workflow is:

sudo dnf install aide
sudo aide --init
sudo mv /var/lib/aide/aide.db.new.gz /var/lib/aide/aide.db.gz
sudo aide --check

Database paths differ between distributions, so check your aide.conf. Initialise the database on a freshly installed system, and copy it to read-only or offline storage. A baseline the attacker can rewrite proves nothing.

Step 6: check loaded kernel modules

A kernel-module rootkit commonly hides by unlinking itself from the kernel’s list of loaded modules. That removes it from lsmod and /proc/modules, which read the same list.

lsmod
cat /proc/modules
ls /sys/module

/sys/module sometimes still shows a module that has hidden from the list. Comparing the two is a classic cross-view check, with one catch: built-in drivers that have parameters also appear in /sys/module, so you will see harmless names there that lsmod never shows. Check those against /lib/modules/$(uname -r)/modules.builtin before worrying. Some rootkits also remove their sysfs entries, so a clean comparison is not proof.

Also check whether the kernel is “tainted”:

cat /proc/sys/kernel/tainted

0 means untainted. Per the kernel documentation, bit 12 (value 4096) means an out-of-tree module was loaded and bit 13 (8192) means an unsigned module was loaded. Proprietary graphics drivers and VirtualBox set these flags legitimately, so a tainted kernel is common on desktops. On a server where you installed no third-party modules, it deserves an explanation.

Step 7: look for hidden processes with unhide

unhide looks for processes that are running but hidden from ps, by comparing ps output with /proc and with information from system calls, and by brute-forcing process IDs.

sudo apt install unhide
sudo unhide proc sys
sudo unhide brute

The companion unhide-tcp does the same for TCP and UDP ports, finding ports in use that ss and netstat do not report.

Step 8: check for eBPF programs

eBPF lets programs run inside the kernel without loading a module. Monitoring and networking tools use it heavily, and so does a newer class of Linux rootkits. Datadog Security Labs documented malware in 2026 that uses eBPF to remove its connections from ss output, kill debuggers that try to attach to it, and stop bpftool listings early so its own programs do not appear.

List what is loaded:

sudo bpftool prog show
sudo bpftool map show
sudo bpftool link show
ls /sys/fs/bpf

On a server, save this output when the system is known to be clean, then compare later. Expect entries from systemd, container runtimes and any monitoring agent. Unexplained programs, especially ones pinned under /sys/fs/bpf so they survive, need investigating. Datadog’s researchers note that malware hiding from bpftool prog show may still be found by querying program IDs one by one with bpftool prog show id N, which uses a different kernel lookup.

Interpreting false positives

Every tool above produces false alarms, and most hits on a healthy system are benign:

The test for any hit: can you tie it to a package with dpkg -S or rpm -qf, and does that package’s verification pass? A file that belongs to no package, in a system directory, with a recent timestamp, is a real lead.

If you confirm a rootkit

Disconnect the machine from the network but leave it powered on if you may want a memory capture, since eBPF programs and memory-only implants disappear on reboot. Rotate every credential and key the system held, from a different machine. Then rebuild from trusted installation media and restore data, not executables, from backups made before the compromise. How to remove a rootkit and the best rootkit scanners cover the next steps, and the kernel-mode rootkits guide explains why cleaning in place is rarely safe.

Frequently asked questions

Is rkhunter still maintained?
The last upstream release is 1.4.6, from February 2018. Distributions such as Debian still package and patch it, so it installs and runs on current systems, but its signature list of known rootkits is old. Treat it as one check among several.
Which is better, rkhunter or chkrootkit?
Neither replaces the other. They test overlapping but different things, both produce false positives, and both run on the system they are checking. Run both, then confirm anything they flag with package verification.
Can a Linux rootkit hide from lsmod?
Yes. A common technique is for a kernel module to unlink itself from the kernel's module list, which removes it from lsmod and /proc/modules. Some still leave traces in /sys/module, and memory forensics can find them by scanning RAM for module structures.
What is an eBPF rootkit?
Malware that loads eBPF programs into the kernel to hide connections, tamper with tool output or block debuggers, without loading a traditional kernel module. bpftool lists loaded eBPF programs, though researchers have shown malware that hides from the standard listing.
Do I need to reinstall if a rootkit is confirmed on a server?
Yes, in almost every case. Once code has run as root or in the kernel, nothing on that system can be trusted. Rebuild from known-good media, restore data rather than binaries from backup, and rotate every credential the server held.