🚧 Under construction — VoTechWorks is being built. A free tech program — complimentary, as our commitment to get America working.
voTechWorksGrade 13 · a vocational technology learning center, by urbanicity
newSchoolWorks.com › VoTechWorks › Technology & Design › Cybersecurity › Linux for Cybersecurity › Lesson 9
TEC-CYBE44-04 · Lesson 9 · 14.5 clock hours · lab

Linux Log Management and Analysis

Objective. Students locate, read, and analyze key Linux log files to identify security events and indicators of compromise.

⚠ Pending professional review

This lesson, its worked examples and its practice questions has not yet been verified by an industry-certified professional or by a certification or approval body. It is a study draft and may contain errors. Do not use it as instructions for work on a job site or on live equipment. Always follow your instructor, your supervising professional, and current official references and regulations.

VoTechWorks program approval and accreditation are still in progress. Credentials are issued only by the certifying bodies named in each program, after their own exams.

Why Log Analysis Matters in Cybersecurity

Every meaningful event on a Linux system — a user login, a failed authentication attempt, a kernel error, a package installation — is recorded in a log file. For a security analyst, logs are the primary evidence trail. The CompTIA CySA+ exam tests your ability to analyze log data under the Security Operations and Monitoring domain, and the ISC2 CC credential expects you to understand incident response fundamentals, which depend heavily on reading logs accurately.

Log analysis is a core daily task in Security Operations Centers (SOCs). Learning to extract, filter, and correlate log data by hand builds the mental model you need to operate SIEM tools effectively.

Key Log Files in /var/log

On Debian and Ubuntu-based Linux systems, most log files live in /var/log. Know what each file records:

On systems using systemd, the journalctl command queries the binary journal, which can include all of the above plus boot messages, service start/stop events, and more. Always check both traditional text logs and the journal during an investigation.

Essential Command-Line Tools

grep filters lines by pattern. To find all failed SSH login attempts in auth.log:

```

grep "Failed password" /var/log/auth.log

```

awk lets you extract specific fields. SSH failure lines contain the source IP in a predictable position. For example:

```

grep "Failed password" /var/log/auth.log | awk '{print $11}'

```

cut extracts columns by delimiter. Combine it with sort and uniq to count unique IPs:

```

grep "Failed password" /var/log/auth.log | awk '{print $11}' | sort | uniq -c | sort -rn

```

This pipeline prints each unique source IP alongside the count of failures, sorted highest to lowest — a fast way to spot a brute-force source.

journalctl filters the systemd journal. To view SSH-related events since midnight:

```

journalctl -u ssh --since today

```

Add -r to reverse chronological order (newest first) and -n 50 to limit output to 50 lines.

Reconstructing a Timeline

When an incident is suspected, your job is to build a timestamped narrative of what happened and in what order. Linux log timestamps are typically in the format Month Day HH:MM:SS. Steps for timeline reconstruction:

1. Identify the approximate window of interest (when did the anomaly begin?).

2. Use grep with a time-range pattern or journalctl's --since and --until flags to narrow scope.

3. Collect relevant lines from multiple log files into a single working file using redirection and append (>>).

4. Sort all lines by timestamp with sort.

5. Read the sorted output and write your narrative, linking each event to its log source.

A well-written incident narrative includes: who (account name or IP), what (action taken), when (timestamp), where (log file and system), and outcome (success or failure).

Centralized Logging with rsyslog

Collecting logs only on the host being attacked creates a risk: an attacker with root access can modify or delete local log files. Forwarding logs to a separate, hardened syslog server addresses this problem. This is the foundation of SIEM log pipelines.

rsyslog is the standard log daemon on most Debian/Ubuntu systems. To forward auth.log entries to a remote server, you edit /etc/rsyslog.conf or add a file in /etc/rsyslog.d/ on the sending host. A basic forwarding rule uses the auth facility and sends over UDP or TCP to the receiving server's IP. On the receiving server, rsyslog must be configured to listen on the appropriate port.

Verify log receipt in real time with:

```

tail -f /var/log/syslog

```

on the receiving server while generating login events on the sending VM.

Log integrity means ensuring logs have not been altered after the fact. Forwarding to a remote server immediately upon generation is a practical first layer. In full SIEM pipelines, cryptographic hashing and chain-of-custody controls add further assurance.

Safety and Best Practices

Key terms9

auth.logA Linux log file (typically at /var/log/auth.log) that records authentication events including SSH logins, sudo use, and PAM activity; a primary source for detecting unauthorized access.
journalctlA command-line utility for querying the systemd binary journal, which aggregates log messages from the kernel, services, and applications with structured metadata.
grepA Linux command that searches text input or files for lines matching a specified pattern, used extensively in log analysis to filter relevant events.
rsyslogThe Reliable System Logger daemon used on many Linux distributions to collect, process, and optionally forward log messages to local files or remote syslog servers.
Brute-force attackAn attack method in which an adversary systematically tries many passwords or credentials against an account, typically visible in auth.log as a high volume of 'Failed password' entries from one source IP.
Privilege escalationAn attack technique in which a user or process gains a higher level of access than intended, often evidenced in auth.log by sudo or su activity following an initial compromise.
Log integrityThe assurance that log records have not been altered or deleted after generation; achieved in practice by forwarding logs to remote servers and applying cryptographic controls in SIEM pipelines.
Indicator of Compromise (IoC)A piece of evidence in logs, network traffic, or files that suggests a system may have been breached, such as repeated failed logins from an unfamiliar IP followed by a successful login.
fail2banAn intrusion prevention service that monitors log files (such as auth.log) for repeated failure patterns and automatically adds firewall rules to block offending IP addresses; activity is recorded in fail2ban.log.
In class: Map the major log files (/var/log/auth.log, syslog, kern.log, dpkg.log, fail2ban.log) to the type of security events each records; perform grep, awk, and cut exercises to extract all failed login attempts from auth.log and count unique source IPs. · Instructor injects a simulated attack scenario into the VM's log files (failed SSH brute force followed by a successful login and privilege escalation); students use journalctl, grep, and sort to reconstruct the timeline of events and write a brief incident narrative. · Configure rsyslog to forward a copy of auth.log entries to a second VM acting as a central syslog server; verify receipt on the server using tail -f and confirm the forwarded messages match the originals — introduce the concept of log integrity for SIEM pipelines (previewing Course 6).
Materials: Two Linux VMs, rsyslog, journalctl, grep, awk, cut, sort, CompTIA CySA+ Study Guide (Security Operations and Monitoring domain), ISC2 CC domain notes on incident response
Check: Students submit the incident narrative with a timestamped event timeline; pass = at least four distinct events correctly identified in sequence, each linked to the correct log source.

Practice check8

Answer each question, then check it. Nothing is recorded; this is your own practice.

Security Operations and Monitoring (CySA+)
1. A security analyst wants to find all lines in /var/log/auth.log that contain the phrase 'Failed password' and then count how many times each unique source IP appears. Which command pipeline correctly accomplishes this?
Security Operations and Monitoring (CySA+)
2. Which Linux log file would most directly show whether an attacker installed a new software package after gaining unauthorized root access?
Security Operations and Monitoring (CySA+)
3. An analyst uses journalctl to investigate SSH activity. Which flag limits the output to events that occurred after a specific date and time?
Incident Response (ISC2 CC)
4. During an incident investigation, a student finds 847 'Failed password' entries from IP 198.51.100.22 in auth.log between 02:14 and 02:19, followed by a single 'Accepted password' entry for the root account at 02:20 from the same IP. What attack sequence does this most strongly indicate?
Security Operations and Monitoring (CySA+)
5. Why is forwarding logs to a remote, centralized syslog server considered a security best practice?
Incident Response (ISC2 CC)
6. A student writes an incident narrative that states: 'The attacker definitely planned this attack for weeks before executing it.' This statement is an example of what problem in incident reporting?
Security Operations and Monitoring (CySA+)
7. Which command would allow an analyst on the central syslog server to watch incoming forwarded log messages in real time as they arrive?
Threats, Attacks and Vulnerabilities (Security+)
8. After reconstructing a timeline, a student identifies these four events in order: (1) 847 failed SSH logins from 198.51.100.22, (2) a successful SSH login as 'jsmith' from the same IP, (3) a sudo command elevating to root, (4) installation of an unknown package via dpkg. Which term best describes the combination of events 1 and 2?
Record this lesson on my transcript. Sign in with your key and enrollment email to record lessons (enroll free if you have no key). This page stays open to read and practise.