Computer & OS Fundamentals · beginner · ~10 min
- Describe the main kinds of logs a system produces (system, authentication, application/web) and what each one records. - Read and write timestamps in unambiguous formats: ISO 8601, UTC, and Unix epoch seconds. - Explain why time zones and clock synchronization (NTP) are required to correlate events across machines. - Walk a small set of log lines and build a basic incident timeline by ordering events. - Recognize the difference between detecting attacks from logs and tampering with logs, and why integrity matters for forensics. - Spot common timestamp mistakes (local time vs UTC, missing offsets, drifted clocks) before they break an investigation.
A log is a written record of things that happened on a computer: a service started, a user logged in, a request arrived, an error was thrown. Each record is a line (or a structured object) with a timestamp saying when it happened, plus details about what happened. Logs are how a running system remembers its own past, long after the program that produced the event has moved on or restarted.
Logs matter because almost nothing in computing leaves a permanent physical trace. If a server is slow at 03:00, or someone's account is accessed from an unexpected place, the only way to find out what occurred is to read the records the system left behind. Operators use logs to debug crashes and performance problems. Security teams use them to detect attacks and to reconstruct exactly what an intruder did, in what order. Auditors use them to prove that controls were followed. This lesson builds directly on the file-system and storage ideas from earlier Computer & OS Fundamentals lessons (the previous lesson, Compression and archives, covered how older logs are rotated and compressed to save space) — logs are just files that grow over time and eventually get archived.
The single most important detail in a log line is usually the timestamp, and timestamps are surprisingly easy to get wrong. A time like 14:30 is meaningless on its own: 14:30 where, and on whose clock? To make timestamps trustworthy and comparable, the industry leans on a few conventions: the ISO 8601 text format, the UTC time standard, and Unix epoch seconds for machine use. Keeping every machine's clock aligned is the job of NTP (the Network Time Protocol). With those pieces in place, you can take logs from a firewall, a web server, and a database, line their events up on one timeline, and see the whole story.
Logs are the backbone of operations, security, and accountability in real software.
None of this works if the times are wrong. If two servers disagree by even a few minutes, a real attack can look like two unrelated events, and a forensic timeline can put effects before their causes. That is why synchronized, unambiguous timestamps are not a nicety — they are what makes a pile of log lines into usable evidence. And because logs are evidence, altering them (outside an authorized, documented process) destroys their value and is treated as a serious offense in any security engagement.
Definition. A log source is any component that records its own events. Different sources answer different questions.
/var/log/ (and in the journald journal); on Windows they appear in the Event Log.sudo). This is the first place a defender looks during a suspected break-in. On Linux these are often in /var/log/auth.log or /var/log/secure.Why it works this way. Each layer can only see its own world, so you correlate across sources: a web log shows a suspicious request, the auth log shows whether it led to a login, the system log shows whether a service then crashed.
When NOT to rely on one source. Never conclude "nothing happened" from a single log. An attacker who only touched the web tier leaves nothing in the auth log; absence in one place is not absence everywhere.
Pitfall. Logs are often sampled or rate-limited under heavy load. A gap can mean "nothing happened" or "too much happened to record" — those are very different.
ENTRY POINT WHAT SEES IT
----------- ------------
user types password ---> auth log (login success/fail)
browser sends GET ---> web log (URL, status, client IP)
service crashes ---> system log (kernel/service error)
One real incident usually leaves traces in SEVERAL logs.
Correlating them = the whole story.
Knowledge check (explain in your own words): Why might a successful attack on a website show up in the web log but leave the authentication log completely empty?
Definition. A timestamp records the instant an event occurred. The format is how that instant is written down.
2026-06-11T14:30:00Z. It goes from largest unit to smallest (year, month, day, then time), uses T to separate the date from the time, and is sortable as plain text — alphabetical order equals chronological order.Z ("Zulu") means "this time is in UTC." A time with an offset like 2026-06-11T16:30:00+02:00 is the same instant expressed in a +2 zone.1970-01-01T00:00:00Z. For example 1749652200. It has no time zone ambiguity at all because it is defined in UTC, and arithmetic on it is trivial (subtract two values to get a duration in seconds).How it works internally. Computers store time as epoch seconds (or milliseconds/nanoseconds) — a plain counter. ISO 8601 strings are produced from that counter for humans to read. Converting between them is just math plus a calendar.
When to use which. Store and transmit time as UTC (epoch or ISO 8601 with Z). Convert to local time only at the moment of display, for the human reading it. Never store local time.
Pitfall. A timestamp with no zone or offset (2026-06-11 14:30:00) is ambiguous — you cannot know what instant it refers to without out-of-band knowledge of the server's configured zone, which may change.
Same instant, three notations:
ISO 8601 (UTC) 2026-06-11T14:30:00Z
ISO 8601 (+02) 2026-06-11T16:30:00+02:00
Unix epoch 1749652200
|
+-- all point to the exact same point on the global timeline
Knowledge check (predict the output): You sort these three text strings alphabetically:
2026-06-11T09:00:00Z,2026-06-11T14:30:00Z,2026-06-11T08:59:59Z. What order do they come out in, and is that the same as chronological order? Why does ISO 8601 make these match?
Definition. A time zone is a regional offset from UTC (e.g. New York is UTC-5 or UTC-4 in summer). NTP, the Network Time Protocol, is the service that keeps a machine's clock continuously aligned with authoritative time servers.
Why it matters for logs. To correlate events across machines, every machine must agree on what time it is. If the web server's clock is 4 minutes ahead of the database's, a request and the query it triggered will look 4 minutes apart — or even out of order. NTP shrinks that disagreement to milliseconds.
How it works internally. Clocks drift — a cheap crystal oscillator gains or loses a few seconds a day. NTP periodically asks reference servers for the true time, measures the network round-trip delay, and gently slews (speeds up or slows down) the local clock to stay aligned, rather than jumping it.
When NOT to: never "fix" a drifted clock by hand-setting it backward on a running system. Jumping the clock backward can make new log lines appear before old ones and confuse software that assumes time only moves forward. Let NTP correct it gradually.
Pitfall. A virtual machine that was paused/suspended can wake with a badly wrong clock until NTP catches up — log lines from that window are suspect.
Without sync With NTP
------------ --------
Web clock: 14:34 ---\ Web clock: 14:30:02
DB clock: 14:30 > 4 min DB clock: 14:30:02
events look unrelated / events line up on ONE timeline
Knowledge check (concept): The quiz for this lesson asks why NTP matters; go one level deeper here — describe a concrete two-server scenario where a 5-minute clock skew makes a single attack look like two separate, unrelated events.
Definition. Detection is using logs to notice that something bad is happening or has happened. Integrity is the guarantee that the logs themselves have not been altered.
Pitfall. Treating your own clock and your own host's logs as ground truth during an incident. If the host is compromised, its local logs may already be tampered with — prefer the copy sent to a separate log server.
Knowledge check (find-the-issue): A teammate says "the server log shows nothing at the time of the breach, so nothing happened then." Give two different innocent-and-not-innocent reasons the log could be empty for that window.
Timestamps you will read and write constantly. The pieces of an ISO 8601 timestamp:
2026-06-11T14:30:00Z
|________| |______||
date time |
YYYY-MM-DD HH:MM:SS
(24-hour)
|
+-- Z = UTC. Or an offset like +02:00 / -05:00
Unix epoch is just an integer of seconds since the 1970 UTC epoch:
1749652200 <-- seconds since 1970-01-01T00:00:00Z
A typical Linux authentication log line, annotated:
Jun 11 14:30:00 web01 sshd[2931]: Failed password for invalid user admin from 203.0.113.9 port 51514 ssh2
|____________| |___| |________| |__________________________________________________________________|
timestamp host program/pid message (what happened, and from where)
Note that the classic syslog timestamp (Jun 11 14:30:00) has no year and no time zone — a real-world ambiguity that modern formats fix. Prefer ISO 8601 with Z wherever you control the format.
Logs are the system's memory of what happened. They are central to both detecting attacks and investigating incidents.
/var/log/ on Linux, the Windows Event Log): service start and stop, authentication attempts, errors.sudo use, failed passwords. This is the first place a defender looks.Every log line is stamped with a time. Two things matter here.
Format. ISO 8601 (for example, 2026-06-11T14:30:00Z) is unambiguous. Many other formats are not.
Time zone. Z means UTC, as opposed to local time. To correlate events across systems, you need a shared time base. That is why NTP (time synchronization) matters.
Unix epoch time, the number of seconds since 1970-01-01 UTC, is the machine-friendly form.
Below is a small, realistic worked example: a slice of raw logs from two systems during a suspected brute-force attempt, followed by the consolidated, normalized timeline a defender would build from them. This is the concept-track "code" — sample data plus the analyst output, not a program.
# --- Raw web server access log (web01), timestamps in UTC (Z) ---
203.0.113.9 - - [2026-06-11T14:29:58Z] "POST /login HTTP/1.1" 401 512
203.0.113.9 - - [2026-06-11T14:29:59Z] "POST /login HTTP/1.1" 401 512
203.0.113.9 - - [2026-06-11T14:30:00Z] "POST /login HTTP/1.1" 401 512
203.0.113.9 - - [2026-06-11T14:30:01Z] "POST /login HTTP/1.1" 200 4096
# --- Raw auth log (app server app02), syslog format, server zone = UTC ---
Jun 11 14:30:01 app02 app[8821]: AUTH success user=alice src=203.0.113.9
Jun 11 14:30:03 app02 app[8821]: ROLE change user=alice new_role=admin
# --- Normalized incident timeline (everything converted to ISO 8601 / UTC) ---
TIME (UTC) SOURCE EVENT
2026-06-11T14:29:58Z web01 POST /login -> 401 (failed) from 203.0.113.9
2026-06-11T14:29:59Z web01 POST /login -> 401 (failed) from 203.0.113.9
2026-06-11T14:30:00Z web01 POST /login -> 401 (failed) from 203.0.113.9
2026-06-11T14:30:01Z web01 POST /login -> 200 (SUCCESS) from 203.0.113.9
2026-06-11T14:30:01Z app02 AUTH success user=alice from 203.0.113.9
2026-06-11T14:30:03Z app02 ROLE change user=alice -> admin
What it does. The raw logs come from two machines in two different formats. The defender's job is to normalize them — convert every timestamp to one format (ISO 8601 / UTC) — and then merge them into one ordered list.
Expected output / what you learn from it. Read top to bottom: three failed logins in three seconds from the same IP (a brute-force pattern), immediately followed by a success on the same IP, the matching AUTH success for user alice on the app server in the same second, and two seconds later that account being promoted to admin. The story is now obvious: the attacker guessed alice's password and escalated privileges. This conclusion is only possible because both servers used UTC and had synchronized clocks — the cross-server events land in the correct order.
Key edge cases. (1) If app02 had been on local time (say UTC+2) without an offset, its 14:30:01 would actually be 12:30:01Z, and the AUTH success would appear before the web success — breaking the causal chain. (2) If the clocks were skewed by even a few seconds, the ROLE change might appear before the login. (3) The syslog line has no year; you must supply it from the log's date range or rotation metadata.
Walk the normalized timeline one event at a time and watch the picture form.
| Step | Time (UTC) | Source | What it tells you |
|---|---|---|---|
| 1 | 14:29:58Z | web01 | First POST /login returns 401 — a failed login from 203.0.113.9. On its own, harmless. |
| 2 | 14:29:59Z | web01 | Second failure, same IP, one second later. A human rarely retries this fast. |
| 3 | 14:30:00Z | web01 | Third failure in three seconds — now it looks like automated guessing (brute force). |
| 4 | 14:30:01Z | web01 | Status flips to 200: a login succeeded from the same IP that was just failing. Strong signal the guess landed. |
| 5 | 14:30:01Z | app02 | The app server records AUTH success for alice from the same IP in the same second. The web success and this are the same login, confirmed across two logs. |
| 6 | 14:30:03Z | app02 | Two seconds after getting in, the account is promoted to admin — privilege escalation. The intruder is expanding access. |
How values change as you read down: the status code moves 401 -> 401 -> 401 -> 200 (failure becoming success), the source IP stays constant (203.0.113.9, the thread that ties everything together), and the privilege jumps from a normal user to admin.
Why the result is trustworthy: every timestamp is in UTC with synchronized clocks, so step 4 (web success) and step 5 (auth success) correctly share the same second and step 6 correctly comes after. Reorder or skew those and the causal chain — guess, succeed, escalate — falls apart. The timeline is the evidence, and its correctness rests entirely on consistent timestamps.
Mistake 1 — Storing local time instead of UTC.
WRONG: logged at "2026-06-11 14:30:00" (no zone; server happens to be in Berlin, UTC+2)
Why it is wrong: six months later daylight saving shifts, or the server moves to another region, and now you cannot tell whether 14:30 meant 12:30Z or 13:30Z. Correlating with a UTC server becomes guesswork.
RIGHT: logged at "2026-06-11T12:30:00Z" (UTC, explicit Z)
Prevent it: configure services to log in UTC; if you must show local time, convert at display time only.
Mistake 2 — Assuming clocks are in sync. Believing two servers agree on the time without running NTP. A 3-minute skew silently splits one incident into two. Recognize it by checking that your hosts run a time-sync service and by comparing a known shared event (e.g. the same request seen in two logs) — if their recorded times differ, you have skew. Prevent it by enabling NTP everywhere and monitoring offset.
Mistake 3 — Sorting non-ISO timestamps as text. Formats like 06/11/2026 2:30 PM do not sort chronologically as strings (12/01 sorts before 06/11, and 2:30 PM sorts before 2:30 AM alphabetically). Learners write a quick text sort and get a scrambled timeline.
WRONG: sort lines like "06/11/2026 2:30 PM" as plain text -> wrong order
RIGHT: use ISO 8601 ("2026-06-11T14:30:00Z") -> text order == time order
Mistake 4 — Trusting a single log source. Concluding "the attacker did nothing on the database" because the web log is quiet about it. Different layers see different things; check the relevant source. Prevent it by always asking "which log would record this action?" before concluding it did not happen.
Mistake 5 — Editing logs to "clean up." Deleting noisy lines (or, during a test, removing one's own activity) destroys evidence and breaks integrity. Even with good intentions, never alter logs in place; filter a copy for readability and keep the original untouched.
When a timeline looks wrong, work through these checks:
Z and no offset? Treat it as unknown zone until you confirm the source machine's configured time zone. Do not assume UTC just because you want it to be..gz archive — see the Compression and archives lesson), or was a section removed? Check file sizes, rotation timestamps, and whether a remote copy on a log server shows the same gap.Robustness, validation, and integrity (this is theory, so focus on correctness and trust):
Concrete uses:
Professional best-practice habits:
Beginner rules
...Z) so logs sort chronologically as text.Advanced practices
Beginner 1 — Convert and label. Given the timestamps 2026-06-11T14:30:00Z, 1749652200 (Unix epoch), and Jun 11 14:30:00, write each one's format name and state which are unambiguous and which are not. Requirement: explain in one sentence why the syslog line is ambiguous. Concepts: ISO 8601, Unix epoch, time-zone ambiguity. Hint: look for an explicit zone marker.
Beginner 2 — Sort a timeline. You are handed five ISO 8601 / UTC log lines in scrambled order. Put them in chronological order using only plain text sorting, then write one sentence explaining why text sorting works here. Input example: lines timestamped 14:30:01Z, 14:29:58Z, 14:30:03Z, 14:29:59Z, 14:30:00Z. Expected output: the lines from earliest to latest. Concepts: ISO 8601 sortability. Hint: alphabetical order should equal time order — verify it does.
Intermediate 1 — Merge two logs. Given a short web log (timestamps in UTC) and a short auth log (syslog format, server zone = UTC), produce a single normalized timeline in ISO 8601 / UTC, then state in one or two sentences what likely happened. Requirement: every line must end up in the same format and be globally ordered. Constraints: do not alter the original lines; build a separate merged view. Concepts: normalization, correlation, log sources. Hint: convert first, merge second.
Intermediate 2 — Find the skew. Two servers each logged the same request (it carries the same request ID req-7f3a). Server A recorded it at 2026-06-11T14:30:00Z; server B at 2026-06-11T14:34:10Z. State the clock skew, explain which event would wrongly appear first if you sorted by time, and name the fix. Concepts: clock skew, NTP, correlation by ID. Hint: the same event cannot truly happen at two different instants.
Challenge — Spot the tampering / the gap. You are given a log excerpt covering 14:25–14:40 UTC, but there are no lines at all between 14:30 and 14:35, and one line at 14:37 has a timestamp of 14:21. List at least three different explanations for the gap (innocent and malicious), describe how you would investigate each (file sizes, rotation/archive timestamps, an off-host copy on a log server), and explain why the out-of-order 14:21 line is a red flag. Constraints: propose investigation steps only — do not fabricate a conclusion. Concepts: integrity, detection, NTP/skew, rotation/archives. Hint: compare against a copy the suspect host could not have edited.
2026-06-11T14:30:00Z) for human-readable, text-sortable times; UTC as the single storage standard; and Unix epoch seconds for unambiguous machine arithmetic.