🐧Linux System Logging Labs

🎯 Objective

Learn to manage and understand system logs using native Linux tools like rsyslog, journald, and logrotate.


🧰 Prerequisites

  • Ubuntu 20.04+ system (VM recommended)

  • Root or sudo access


πŸ”Ή Lab 1: Understanding the Logging Stack

Ubuntu uses:

  • journald (systemd journal) for structured logging

  • rsyslog for traditional syslog compatibility

  • logrotate for rotating log files


πŸ”Ή Lab 2: View Logs with journalctl

Step 1: View the entire system log

Step 2: View logs for a specific service

Step 3: Follow logs in real-time

βœ… journalctl is the main tool for querying system logs.


πŸ”Ή Lab 3: Configure Persistent Journaling

By default, journald logs may be in memory only.

Make logs persistent

βœ… Logs will now survive reboots.


πŸ”Ή Lab 4: Explore Traditional Log Files with rsyslog

βœ… Use these for classic log file views.


πŸ”Ή Lab 5: Create a Custom rsyslog Rule

Step 1: Create a custom log file

Step 2: Restart rsyslog

Step 3: Test the rule

βœ… Custom logs go to your specified file.


πŸ”Ή Lab 6: Configure Log Rotation with logrotate

View the config:

Manually trigger rotation:

βœ… Helps prevent logs from filling the disk.


πŸ”Ή Lab 7: Secure Your Logs

Ensure correct permissions

βœ… Only root can read/write logs.


βœ… Wrap-Up

  • βœ… Explored journalctl and rsyslog

  • βœ… Created persistent journal and custom log rules

  • βœ… Set up log rotation and secured logs


Last updated