Study guide
11.3 Monitoring and Logging
Kali Linux Certified Professional KLCP
Track your progress as you read
Finished sections get a check mark.
1 Introduction & Exam Overview
1.1 Current Exam Facts 1.2 How to Use This Guide & Study Strategy 1.3 PEN-103 Syllabus & Study Path
2 About Kali Linux
2.1 A Bit of History: From BackTrack to Kali 2.2 Kali's Relationship with Debian 2.3 Purpose and Use Cases 2.4 Main Features and Design Policies
3 Getting Started with Kali Linux
3.1 Downloading and Verifying a Kali ISO 3.2 Booting Kali in Live Mode 3.3 Installation Options Overview 3.4 Troubleshooting Installations
4 Linux Fundamentals
4.1 What Linux Is and What It Does 4.2 The Command Line 4.3 The Filesystem Hierarchy Standard 4.4 Useful Commands: Files, Search, Environment
5 Permissions and Process Management
5.1 File Permissions and Ownership 5.2 Managing Processes 5.3 Shells, Variables, and the Environment
6 Installing Kali Linux
6.1 Minimal Installation Requirements 6.2 Step-by-Step Installation on a Hard Drive 6.3 Unattended Installations with Preseeding 6.4 ARM Installations
7 Configuring the Network, Users, and SSH
7.1 Configuring the Network 7.2 Managing Unix Users and Groups 7.3 Configuring SSH
8 Configuring Services
8.1 Apache Web Server 8.2 PostgreSQL Database 8.3 Managing Services with systemd
9 Helping Yourself and Getting Help
9.1 Documentation Sources 9.2 Kali Linux Communities 9.3 Filing Good Bug Reports
10 Security Policy and Network Services
10.1 Defining a Security Policy 10.2 Possible Security Measures 10.3 Securing Network Services
11 Firewalling and Monitoring
11.1 Netfilter and iptables Behavior 11.2 Writing iptables Rules and NAT 11.3 Monitoring and Logging
12 Debian Package Management: APT
12.1 Introduction to APT 12.2 The sources.list File 12.3 Kali Repositories 12.4 Basic Package Interaction with apt
13 dpkg and Advanced Package Management
13.1 dpkg Fundamentals 13.2 Inspecting .deb Files and Package State 13.3 Maintainer Scripts and Conffiles 13.4 APT Pinning and Package Authenticity
14 Advanced Usage
14.1 Modifying and Rebuilding Kali Packages 14.2 Recompiling the Kernel 14.3 Building Custom Kali Live ISO Images 14.4 USB Persistence with LUKS Encryption
15 Kali Linux in the Enterprise
15.1 Network Installation with PXE Boot 15.2 Configuration Management with SaltStack 15.3 Metapackages and Custom Repositories 15.4 Configuration Packages and Forking
16 Introduction to Security Assessments
16.1 Kali Linux in an Assessment 16.2 Types of Assessments 16.3 Types of Attacks 16.4 Formalization and the Road Ahead
11.3 Monitoring and Logging
Key Takeaways Explain This Topic AI
rsyslog writes traditional text logs under /var/log (syslog, auth.log, kern.log), while systemd's journal is queried with journalctl.
journalctl -u <unit>, -b (current boot), -f (follow), and --since are the core filtering flags for the systemd journal.
logrotate, configured in /etc/logrotate.conf and /etc/logrotate.d/, rotates, compresses, and prunes log files on a schedule.
logcheck emails summaries of anomalous log entries; rkhunter and chkrootkit scan for known rootkits and signs of compromise.
AIDE creates a cryptographic baseline database of file attributes (aideinit) and reports changes with aide --check — initialize it on a clean system before exposure.
Last updated: July 2026
11.3 Monitoring and Logging
A firewall controls what gets in; monitoring tells you what actually happened. Kali inherits Debian's full logging and auditing toolchain, and the KLCP exam expects you to know which tool answers which question: where logs live, how to query them, how they're rotated, and how to detect that a machine has been tampered with.
rsyslog and the /var/log Layout
rsyslog is the traditional system logging daemon. It receives messages tagged with a facility (what subsystem produced them: auth, kern, mail, daemon...) and a priority (severity from debug up to emerg), then routes them according to /etc/rsyslog.conf and files under /etc/rsyslog.d/ . The result is the classic text-file layout in /var/log :
- File Contents
- /var/log/syslog General system activity
- /var/log/auth.log Authentication events: logins, sudo, SSH attempts
- /var/log/kern.log Kernel messages — including your iptables LOG target output
- /var/log/dpkg.log Package installs/removals
- /var/log/apt/ APT history and term logs
You can inject your own test messages with the logger command ( logger -p auth.warning 'test message' ), which is handy for verifying routing rules. Firewall log lines from section 11.2's LOG target arrive via the kernel facility, so they land in kern.log (and typically syslog as well).
journalctl and the systemd Journal
Alongside rsyslog, systemd captures service output and metadata in a binary journal , queried with journalctl . The journal is not a replacement you can ignore — on a systemd-based Kali, much service output (including early-boot messages) exists only in the journal. Core flags:
- journalctl -u ssh.service — logs for one unit
- journalctl -b — current boot only ( -b -1 for the previous boot)
- journalctl -f — follow, like tail -f
- journalctl --since '2026-07-26 08:00' --until '2026-07-26 09:00' — time window
- journalctl -p err — filter by priority (err and above)
- journalctl -k — kernel messages, like dmesg
By default the journal may be volatile (kept in /run/log/journal and lost at reboot); creating /var/log/journal/ or setting Storage=persistent in /etc/systemd/journald.conf makes it survive reboots.
logrotate
Logs grow without bound unless something prunes them. logrotate — run daily via systemd's logrotate.timer (historically cron.daily) — rotates, compresses, and eventually deletes old logs. Global settings live in /etc/logrotate.conf ; per-service drop-ins live in /etc/logrotate.d/ . A stanza specifies the rotation frequency ( weekly ), how many generations to keep ( rotate 4 ), whether to compress old logs ( compress ), and what to do after rotation (often reloading the daemon so it reopens its log file). Knowing where these files live is a favorite exam check.
logcheck: Pushed Log Review
Nobody reads syslog cover to cover every morning. logcheck automates the review: it runs hourly by default , reads the files listed in /etc/logcheck/logcheck.logfiles , filters out known-boring entries using the rule sets under /etc/logcheck/cracking.d/ , /etc/logcheck/violations.d/ and /etc/logcheck/ignore.d.{paranoid,server,workstation}/ , and emails a digest of everything anomalous to the administrator. Its personality is set by a reporting level in /etc/logcheck/logcheck.conf — workstation (very aggressive filtering), server (the default), or paranoid (report almost everything). The value for the exam is conceptual: logcheck inverts monitoring from pull (you remember to look) to push (anomalies come to you).
Rootkit Scanners: rkhunter and chkrootkit
If an attacker does get in, their next move is usually hiding. Rootkits replace or subvert system binaries (ps, ls, netstat, login) to conceal processes, files, and connections. Kali's two classic scanners:
rkhunter (Rootkit Hunter): checks for known rootkit signatures, suspicious file properties and permissions, hidden files, wrong strings in common binaries, and unexpected network ports. Typical workflow: rkhunter --update to refresh its data, rkhunter --check to scan, and rkhunter --propupd to accept a new baseline after legitimate system updates — otherwise yesterday's apt upgrade becomes today's false positive storm.
chkrootkit : a lighter, complementary scanner that checks system binaries against signatures of known rootkits and looks for telltales like interfaces in promiscuous mode or tampered lastlog / wtmp / utmp records. Running just chkrootkit performs the standard battery of tests.
Run both; they overlap but catch different things. Neither is authoritative — treat alerts as leads, not verdicts.
Real-Time Activity: top
top is the interactive process monitor the book singles out: it lists running processes sorted by CPU use by default, and you re-sort with P (CPU), M (memory), T (cumulative CPU time) and N (PID). k kills a process by PID and r renices one. The security value is pattern recognition — an unfamiliar process running as www-data , or eating CPU on a box that hosts nothing, is exactly the anomaly worth chasing. Each desktop also ships a graphical equivalent ( xfce4-taskmanager on Kali's Xfce, gnome-system-monitor , ksysguard ).
Auditing Packaged Files with dpkg --verify
dpkg --verify (or dpkg -V ) compares installed files against the MD5 checksums dpkg recorded at install time in /var/lib/dpkg/info/<package>.md5sums , printing one line per file that fails. Each character of the leading field is one metadata test; dpkg only implements two of them — position 2 (file mode, shown as M ) and position 3 (MD5 digest, shown as 5 ) — so every other position is permanently ? : # dpkg -V
- ??5?????? /lib/systemd/system/ssh.service
- ??5?????? c /etc/libvirt/qemu/networks/default.xml
The letter after the code marks the file type: c means a conffile, so the second line is a legitimately edited configuration file, while the first is a packaged unit file someone modified in place instead of using a systemd override. Know the tool's limit: an attacker with root can rewrite those md5sums files, so dpkg -V is a triage aid, not proof — APT's signature verification is the real defence.
AIDE: File-Integrity Monitoring
AIDE (Advanced Intrusion Detection Environment) takes the opposite approach to signature scanning: it builds a cryptographic database of file attributes — hashes, sizes, permissions, timestamps — and later reports anything that changed. The workflow is strict about ordering:
Install AIDE on a known-clean system and run aideinit . On Debian and Kali that wrapper runs aide --init , writes the new database to /var/lib/aide/aide.db.new , and installs it as the reference database /var/lib/aide/aide.db — it only stops to ask if a reference database already exists.
Let the packaged daily job ( /etc/cron.daily/aide ) do the checking, or run one by hand with aide.wrapper --check ; the Debian wrapper regenerates the runtime configuration from /etc/aide/aide.conf and /etc/aide/aide.conf.d/ before calling aide . Findings land in /var/log/aide/ and in the administrator's mail.
Each daily run writes a candidate database to /var/lib/aide/aide.db.new . When every reported change was legitimate — say an apt full-upgrade — promote that file over /var/lib/aide/aide.db to re-baseline; otherwise investigate before you overwrite anything.
Configuration lives in /etc/aide/aide.conf , which defines which paths are watched and which attributes are compared per path. The integrity of the whole scheme rests on the baseline being clean — initialize it before the box ever touches an untrusted network, and ideally store a copy of the database offline, since a competent attacker who owns the box can re-baseline AIDE to hide their changes.
The Intrusion-Detection Mindset for a Pentest Box
Why does a machine built for offense need defense? Because your Kali box is itself a high-value target: it holds engagement notes, credentials harvested during tests, exploit code, and client data. Compromise of the pentest platform is a reportable incident for your client. So layer the basics: default-DROP firewall rules, services enabled only when needed (Kali already ships with SSH, Apache, and PostgreSQL disabled by default), persistent journals, logcheck or equivalent alerting, periodic rkhunter/chkrootkit runs, and an AIDE baseline taken on day one. Monitoring is not about achieving perfect prevention; it is about shortening the time between compromise and detection — and on an assessment, being able to prove your own infrastructure stayed clean.