Copied
Module 11 β€’ Beginner Level β€’ Animated Interactive Reference

Logs and Troubleshooting

Learn how Linux leaves clues. You will read journalctl, explore /var/log, inspect service logs, check boot/kernel logs, and follow a simple method to troubleshoot like a calm field engineer.

πŸ“œ
LogsSystem memory of events
🎯
FiltersService, time, priority
🧭
MethodSymptom β†’ clues β†’ cause
Incident Console
$ systemctl status sshd ● sshd.service - OpenSSH server daemon Active: failed (Result: exit-code) $ journalctl -u sshd --since "10 minutes ago" sshd[842]: Bad configuration option: PermitRootLoginn Detective note: typo in sshd_config found πŸ†

1. Why logs matter

A log is a timestamped clue. When something starts, fails, restarts, gets blocked, authenticates, times out, or crashes, Linux usually writes a record somewhere. Troubleshooting is the art of asking the right log the right question.

🧾

Linux logs

Records of system, service, security, kernel, application, and boot events.

🧠

journalctl

The main viewer for systemd journal logs. Best for service and boot troubleshooting.

πŸ“

/var/log

Traditional log files. Useful for distro-specific, application, auth, package, and rotated logs.

βš™οΈ

dmesg

Kernel ring buffer. Useful for boot, driver, disk, hardware, and kernel messages.

2. First 5 minutes of troubleshooting πŸš‘

When a server is behaving badly, do not start with random fixes. Start with a fast health scan, capture the time window, then narrow the problem.

Emergency starter checklist

Use this when the problem is unclear: slow server, failed login, broken app, or β€œsomething is not working.”

date
uptime
df -h
free -h
systemctl --failed
journalctl -p err -b --no-pager
dmesg | tail
Field habit: write down the exact problem time. Logs are easiest when you know the time window.

Troubleshooting pyramid

Root Cause
Specific Logs
Service Status
System Health
User Symptom

Start at the bottom: symptom β†’ health β†’ service β†’ logs β†’ root cause. This stops β€œcommand gambling.”

Memory hook: LOGS method 🧠

L
Locate
Find the right log source.
O
Observe
Check timestamp, unit, severity.
G
Grep/filter
Reduce noise using service/time.
S
Solve safely
Fix one cause, then verify.

3. Linux Log Map πŸ—ΊοΈ

Use this map to decide where to look. Click a log source to see what it means and when to use it.

Linux Event systemd-journaldcollector / black box journalctlread journal logs /var/logtraditional files dmesgkernel buffer service logsjournalctl -u sshd boot logsjournalctl -b auth logssecure / auth.log
Blue = journalYellow = filesGreen = kernel

Click the map

Pick any block on the left. The explanation will appear here with commands and field use.

Mental model: journalctl is the black box recorder, /var/log is the file cabinet, and dmesg is the kernel’s quick memory.

systemd-journald

Collects logs from services, kernel, boot process, and system components. You usually read it through journalctl.

journalctl --disk-usage
journalctl --list-boots

journalctl

Best first tool for modern Linux troubleshooting, especially for failed services and boot issues.

journalctl -xe
journalctl -u sshd --since "15 minutes ago"
journalctl -p err

/var/log

Traditional logs live here. Names differ by Linux family.

PurposeUbuntu/DebianRocky/RHEL
General system/var/log/syslog/var/log/messages
Authentication/var/log/auth.log/var/log/secure

dmesg

Shows kernel ring buffer messages. Very useful for boot, drivers, disks, network cards, USB, and hardware clues.

dmesg | tail
sudo dmesg -T | tail
journalctl -k

Service logs

Use service-specific logs when one daemon is failing. This gives a cleaner signal than reading every log on the machine.

systemctl status sshd
journalctl -u sshd -f
journalctl -u sshd --since "today"

Boot logs

Use boot logs when the machine booted slowly, failed to mount something, loaded a bad driver, or had startup service failures.

journalctl -b
journalctl -b -1
systemd-analyze blame

Authentication logs

Use these for SSH login failures, sudo activity, invalid users, brute-force attempts, and privilege escalation traces.

# Rocky/RHEL
sudo tail -f /var/log/secure

# Ubuntu/Debian
sudo tail -f /var/log/auth.log

4. Animated log flow πŸ“œβž‘οΈπŸ§ 

A service event moves through the system before you read it. This animation explains why the same event may be visible through journalctl and sometimes also in /var/log.

πŸšͺ
EventSSH login fails
🧩
Servicesshd reports it
🧠
Journaljournald captures it
🧾
Viewerjournalctl displays it
πŸ“
Filesrsyslog may write files

5. How to read one log line πŸ‘€

Beginners often run the right command but miss the clue. Click each part of the log line.

Aug 09 20:15:42 server01 sshd[1842]: Failed password for invalid user admin from 192.168.1.50 port 55218 ssh2
Click a highlighted part

Its meaning will appear here.

6. journalctl command playground πŸ§ͺ

Start broad only when you are lost. In real troubleshooting, filter by service, time, boot, and severity as quickly as possible.

Core commands

# Recent important logs, jump to end
journalctl -xe

# Logs for current boot
journalctl -b

# Previous boot
journalctl -b -1

# Kernel messages from journal
journalctl -k
Field note: journalctl -xe is useful, but not magic. For a failing service, journalctl -u <service> is usually cleaner.

Better filters

# SSH logs only
journalctl -u sshd

# Follow SSH logs live
journalctl -u sshd -f

# Last 15 minutes
journalctl -u sshd --since "15 minutes ago"

# Only errors and worse
journalctl -p err
Professional habit: filter logs before guessing fixes. Guessing causes noise; logs reduce it.

Break down: journalctl -xe

PartMeaning
journalctlRead systemd journal logs.
-xAdd explanatory text where available.
-eJump to the end of the logs.

Bad command vs better command

Weak approachBetter approach
journalctl -xe foreverjournalctl -u sshd --since "10 minutes ago"
Read all logs manuallyFilter by service, boot, time, priority
Restart repeatedlyRead logs first, then restart once

7. journalctl filtering mastery 🎯

The skill is not β€œrun journalctl.” The skill is asking the journal a narrow question: which service, which boot, which time, and which severity?

Most useful filters

NeedCommandUse when
Current bootjournalctl -bProblem happened after current startup.
Previous bootjournalctl -b -1System rebooted or crashed earlier.
Time rangejournalctl --since "1 hour ago"You know roughly when it failed.
Servicejournalctl -u sshdOne daemon is failing.
Live followjournalctl -u sshd -fYou want to watch while reproducing the issue.
Kerneljournalctl -kHardware, driver, boot, disk, NIC issue.
Errors onlyjournalctl -p errLogs are too noisy.

Copy-ready filter pack

journalctl -b
journalctl -b -1
journalctl --since "1 hour ago"
journalctl --since today
journalctl -u sshd -f
journalctl -p warning
journalctl -p err..alert
journalctl -k
journalctl --no-pager
journalctl -o short-iso
Beginner trap: journalctl -xe is useful, but it is not magic. For real troubleshooting, filter by service and time.

Timestamp range example

Use exact windows during incidents, especially in production or classroom evidence capture.

journalctl --since "2026-08-09 10:00" --until "2026-08-09 10:30" --no-pager

8. /var/log and distro differences 🐧

Your lab commands include tail -f /var/log/messages, which is right for Rocky/RHEL. On Ubuntu/Debian, the usual equivalent is /var/log/syslog.

Rocky/RHEL family

# General system logs
sudo tail -f /var/log/messages

# Authentication and sudo logs
sudo tail -f /var/log/secure

# Package manager logs
sudo less /var/log/dnf.log

Ubuntu/Debian family

# General system logs
sudo tail -f /var/log/syslog

# Authentication and sudo logs
sudo tail -f /var/log/auth.log

# Package manager logs
sudo less /var/log/apt/history.log

Common idea

Traditional file logs are still valuable, especially when applications write to files directly or when older operational runbooks expect file-based logs.

# Watch a file live
sudo tail -f /path/to/logfile

# Search a file for errors
sudo grep -i error /path/to/logfile

# Follow last 100 lines live
sudo tail -n 100 -f /path/to/logfile

9. Log reading tools: less, grep, tail, head πŸ”

File logs can be huge. Beginners often use cat and flood the terminal. Use reading and filtering tools instead.

lessRead safely
less /var/log/messages
grepSearch clues
grep -i error file
tailLatest lines
tail -n 50 file
tail -fLive watch
tail -f file
headBeginning
head file

Rocky/RHEL examples

sudo less /var/log/messages
sudo grep -i error /var/log/messages
sudo grep -i failed /var/log/secure
sudo tail -n 50 /var/log/messages
sudo tail -f /var/log/messages

Ubuntu/Debian examples

sudo less /var/log/syslog
sudo grep -i error /var/log/syslog
sudo grep -i failed /var/log/auth.log
sudo tail -n 50 /var/log/syslog
sudo tail -f /var/log/syslog

10. Common service troubleshooting workflow πŸ› οΈ

When one service fails, follow a repeatable sequence. Do not restart blindly; first collect the failure reason.

Safe service workflow

Check service state
systemctl status SERVICE
Read service logs
journalctl -u SERVICE --since "30 minutes ago"
Inspect unit/config
systemctl cat SERVICE
Fix one thing
Config, port, permission, dependency, package, or path.
Restart and verify
sudo systemctl restart SERVICE

Copy-ready workflow

systemctl status SERVICE
journalctl -u SERVICE --since "30 minutes ago" --no-pager
systemctl cat SERVICE
sudo systemctl restart SERVICE
systemctl status SERVICE
journalctl -u SERVICE --since "5 minutes ago" --no-pager
Production rule: restarting may cause impact. Check logs first, communicate if needed, then change one thing at a time.

11. Authentication troubleshooting πŸ”

SSH and sudo issues are common beginner incidents. The key is knowing the log path and service name for the distro family.

Rocky/RHEL

systemctl status sshd
journalctl -u sshd --since "30 minutes ago"
sudo tail -f /var/log/secure
sudo grep -Ei "failed|invalid|accepted|refused" /var/log/secure

Ubuntu/Debian

systemctl status ssh
journalctl -u ssh --since "30 minutes ago"
sudo tail -f /var/log/auth.log
sudo grep -Ei "failed|invalid|accepted|refused" /var/log/auth.log

Common SSH clues

Log clueLikely meaningNext check
Failed passwordWrong password or brute-force attempt.User, source IP, auth method.
Invalid userUsername does not exist.id USER, account creation.
Accepted publickeySuccessful key-based login.Confirm user and source IP.
Authentication refusedOften permissions or account policy.Home dir, .ssh permissions, account lock.
Connection closedClient disconnected or policy refused session.Server policy, firewall, client logs.

12. Boot and kernel deep dive πŸ‰

Boot logs and kernel logs tell you about startup, drivers, disks, memory pressure, network links, and hardware-level symptoms.

Boot troubleshooting

journalctl -b
journalctl -b -1
journalctl -p err -b
systemd-analyze
systemd-analyze blame
systemd-analyze critical-chain
systemctl --failed
20:10 Server starts booting.
20:11 A mount waits too long.
20:14 Boot completes slowly.
20:15 Admin checks systemd-analyze blame.

Kernel / hardware clues

dmesg | tail
sudo dmesg -T | tail
dmesg | grep -i error
journalctl -k
journalctl -k -p err
ClueMeaning to investigate
I/O errorDisk/storage path issue.
EXT4-fs errorFilesystem problem.
Out of memoryOOM killer or memory pressure.
segfaultProcess crashed at memory level.
NIC link downNetwork interface/link issue.
blocked for more than 120 secondsPossible storage or kernel wait.

13. Log rotation and disk-full recovery 🧹

Logs are useful, but they can also fill disks. Learn the safe way to inspect log growth and reduce journal usage.

Find log growth

df -h
journalctl --disk-usage
sudo du -sh /var/log/* | sort -h
ls -lh /var/log

Look for unusually large files, old rotated logs, compressed files like .gz, and services writing too much.

Safe cleanup examples

# Reduce systemd journal safely
sudo journalctl --vacuum-time=7d
sudo journalctl --vacuum-size=500M

# Test logrotate config without changing files
sudo logrotate -d /etc/logrotate.conf
Do not: randomly delete active security, audit, database, or application logs in production. Preserve evidence first.

14. Severity levels: log alarm scale 🚦

Use priority filters when logs are too noisy. Click a severity card.

emerg
0 β€’ system unusable
alert
1 β€’ act now
crit
2 β€’ critical
err
3 β€’ errors
warning
4 β€’ warning
notice
5 β€’ notable
info
6 β€’ normal info
debug
7 β€’ verbose

Pick an alarm level

The command and meaning will appear here.

15. Common troubleshooting method 🧭

Use the S.C.A.N. method: Symptom β†’ Check service/system state β†’ Analyze logs β†’ Narrow root cause.

πŸ“£

S β€” Symptom

What exactly is broken? Since when? Who is affected?

🩺

C β€” Check

Check service status, disk, network, CPU, and recent changes.

πŸ”¬

A β€” Analyze

Filter logs by time, service, priority, and boot.

🎯

N β€” Narrow

Prove the likely cause before changing the system.

16. Real incident cards 🚨

Short field-style scenarios. Read the symptom, inspect the clues, then choose the likely root cause.

Incident 1: SSH service not starting

Symptom: users cannot SSH into the server.

systemctl status sshd
journalctl -u sshd --since "10 minutes ago"
sshd[842]: Bad configuration option: PermitRootLoginn

Incident 2: Disk full

Symptom: application says β€œNo space left on device.”

df -h
sudo du -sh /var/log/*
journalctl --disk-usage
write failed: No space left on device

Incident 3: Boot slow

Symptom: server takes several minutes to boot.

systemd-analyze
systemd-analyze blame
journalctl -b
A start job is running for /mnt/backup

17. Spot the error 🧠

Click the best answer. This builds pattern recognition, which is half of troubleshooting.

Question 1

sshd[1234]: Bind to port 22 on 0.0.0.0 failed: Address already in use.

Question 2

Which command shows logs for the SSH service on Rocky/RHEL?

Question 3

Which command shows kernel messages?

Question 4

What is the Ubuntu/Debian equivalent of /var/log/messages for general system logs?

Quiz score:0 / 4

18. Hands-on labs βœ…

Run these on a safe training VM. Use two terminals where live-follow commands are involved. The checklist saves progress in your browser.

Lab A: Recent important logs

journalctl -xe

Goal: identify timestamp, hostname, unit/service name, and actual message.

Lab B: Service logs

systemctl status sshd
journalctl -u sshd
journalctl -u sshd -f
systemctl status ssh
journalctl -u ssh
journalctl -u ssh -f

Lab C: Watch /var/log live

# Rocky/RHEL
sudo tail -f /var/log/messages

# Ubuntu/Debian
sudo tail -f /var/log/syslog

In another terminal, restart a harmless service and watch log movement.

# Rocky/RHEL
sudo systemctl restart sshd

# Ubuntu/Debian
sudo systemctl restart ssh

Lab D: Boot and kernel logs

journalctl -b
dmesg | tail
journalctl -k
systemd-analyze blame
Note: On some systems, dmesg may require sudo due to kernel security settings.

Lab E: First 5-minute scan

date
uptime
df -h
free -h
systemctl --failed
journalctl -p err -b --no-pager

Lab F: Journal filtering practice

journalctl -b --no-pager | tail -30
journalctl --since "1 hour ago" --no-pager
journalctl -p warning --no-pager
journalctl -k --no-pager | tail -30

Lab progress

0 of 7 complete

19. Troubleshooting evidence capture script πŸ“¦

This is useful for classroom labs and real incidents. It collects basic state without changing the system.

Safe evidence bundle

cat > collect-troubleshooting-evidence.sh <<'EOF'
#!/usr/bin/env bash
set -u

OUT="troubleshooting-evidence-$(hostname)-$(date +%F-%H%M%S)"
mkdir -p "$OUT"

{
  echo "Hostname: $(hostname)"
  echo "Date: $(date)"
  echo "Kernel: $(uname -a)"
} > "$OUT/summary.txt"

uptime > "$OUT/uptime.txt" 2>&1
free -h > "$OUT/memory.txt" 2>&1
df -h > "$OUT/disk.txt" 2>&1
systemctl --failed > "$OUT/failed-services.txt" 2>&1
journalctl -p err -b --no-pager > "$OUT/current-boot-errors.txt" 2>&1
journalctl -k --no-pager | tail -200 > "$OUT/kernel-tail.txt" 2>&1
dmesg | tail -200 > "$OUT/dmesg-tail.txt" 2>&1

tar -czf "$OUT.tar.gz" "$OUT"
echo "Evidence saved to $OUT.tar.gz"
EOF
chmod +x collect-troubleshooting-evidence.sh
./collect-troubleshooting-evidence.sh

Good evidence habits

  • Capture exact time and hostname.
  • Collect before clearing logs.
  • Keep original logs unchanged.
  • Attach evidence bundle to ticket/incident notes.

Avoid this

  • Deleting logs first.
  • Restarting repeatedly without reading logs.
  • Mixing many fixes at once.
  • Ignoring time zones and timestamps.

20. Practice incidents with hidden answers 🧩

Read the symptom, decide what you would check, then open the answer. This is where learners start thinking like troubleshooters.

Incident A: SSH login fails after password change
AuthSSHBeginner

Symptom: User cannot SSH, but the server is reachable.

# Rocky/RHEL
sudo grep -Ei "failed|invalid|accepted|refused" /var/log/secure
journalctl -u sshd --since "30 minutes ago"

# Ubuntu/Debian
sudo grep -Ei "failed|invalid|accepted|refused" /var/log/auth.log
journalctl -u ssh --since "30 minutes ago"

Likely answer: wrong password, locked account, wrong username, or SSH policy. Match the username, source IP, and exact timestamp.

Incident B: Service fails after config edit
ServiceConfig

Symptom: Service worked before a config change, then restart failed.

systemctl status SERVICE
journalctl -u SERVICE --since "15 minutes ago" --no-pager
systemctl cat SERVICE

Likely answer: syntax error, invalid option, bad path, permission problem, or missing dependency. Fix one line, restart once, verify logs.

Incident C: Disk full because logs grew
DiskLogrotate

Symptom: App errors show No space left on device.

df -h
journalctl --disk-usage
sudo du -sh /var/log/* | sort -h
sudo logrotate -d /etc/logrotate.conf

Likely answer: one log file or journal storage is consuming space. Use logrotate or journal vacuum; do not randomly delete evidence.

Incident D: Server boot is very slow
Bootsystemd

Symptom: Boot takes several minutes after adding a mount or network dependency.

systemd-analyze
systemd-analyze blame
systemd-analyze critical-chain
journalctl -b --no-pager
systemctl --failed

Likely answer: slow mount, network wait, failed unit, DNS delay, or broken dependency.

Incident E: Kernel reports disk I/O errors
KernelStorageHigh priority

Symptom: Application freezes and logs show storage errors.

dmesg | grep -Ei "i/o error|ext4-fs error|blk|reset|timeout"
journalctl -k -p warning --no-pager
lsblk
findmnt

Likely answer: disk, filesystem, controller, SAN/NAS, or VM storage issue. Preserve logs and escalate carefully.

21. Final boss mission: SSH is down πŸ§Ÿβ€β™‚οΈ

Solve the incident using the proper troubleshooting sequence. Pick the best next step each time.

Incident brief

Users cannot SSH into server01. A change was made 10 minutes ago. Your job is to find the likely cause without random guessing.

Start

22. Field engineer cheat sheet 🧰

Keep this section. It is the β€œpanic calmly” page for real work.

Fast commands

# Recent important logs
journalctl -xe

# Current boot logs
journalctl -b

# Previous boot logs
journalctl -b -1

# Kernel logs
journalctl -k
dmesg | tail

# Service logs
journalctl -u sshd

# Follow service logs live
journalctl -u sshd -f

# Only errors and worse
journalctl -p err

# Logs since a time
journalctl --since "30 minutes ago"

# Journal storage usage
journalctl --disk-usage

Mini runbook: service failed

systemctl status SERVICE
journalctl -u SERVICE --since "15 minutes ago"
systemctl cat SERVICE
sudo SERVICE_BINARY --test-config  # if supported

Mini runbook: logs too noisy

journalctl -p err
journalctl -u SERVICE
journalctl --since "YYYY-MM-DD HH:MM"
journalctl -b

Beginner rules

  • Check the exact time the problem happened.
  • Filter by service before reading everything.
  • Read the first real error, not only the last line.
  • One change at a time; then re-check logs.
  • Save evidence before clearing logs.

Printable one-page cheat sheet πŸ–¨οΈ

Use the browser print button. In print view, navigation and voice controls are hidden.

System health

date
uptime
df -h
free -h
systemctl --failed

Journal basics

journalctl -xe
journalctl -b
journalctl -b -1
journalctl -p err -b
journalctl --since "1 hour ago"

Services and kernel

systemctl status SERVICE
journalctl -u SERVICE
journalctl -u SERVICE -f
journalctl -k
dmesg | tail

File logs

# Rocky/RHEL
sudo tail -f /var/log/messages
sudo tail -f /var/log/secure

# Ubuntu/Debian
sudo tail -f /var/log/syslog
sudo tail -f /var/log/auth.log
πŸ”Š Voice guide
Voice is optional. It uses your browser’s speech engine and defaults to English when available.