LESSON 24 · BEGINNER4 min read

Project: Audit a Linux Server Against a Baseline

Review accounts, privileges, services, updates, and logging on a lab server, then produce a prioritised hardening report.

OWASP Top 10 · MITRE ATT&CK · NIST CSF 2.0Free to readModule 5 of 14
YOUR NEXT SMALL WINS

By the end, you’ll be able to…

  • Build a repeatable baseline checklist for a Linux host.
  • Collect evidence with read-only commands and record the host context.
  • Distinguish critical findings from hardening opportunities.
  • Write a remediation plan with owners, risk, and verification steps.

01What a Baseline Is and Is Not

A baseline is a documented, repeatable definition of an acceptable configuration. It might require automatic security updates, SSH key authentication only, no direct root login, a host firewall, audit logging, and a defined list of approved services. A baseline is not a guarantee of security, and a host that matches the baseline can still run vulnerable software.

Baselines exist so that reviews are consistent. Without one, every auditor invents a different definition of 'hardened' and findings cannot be compared over time. Start with a recognised source such as the CIS Benchmarks, the distribution's security guidance, or your organisation's policy. Then adapt it to the system's role. A public web server and an internal build agent should not have identical rules.

The audit itself should be read-only. You are collecting evidence, not changing the system. If you find a critical issue, do not fix it during the audit unless the rules of engagement say so. Record the state, preserve the evidence, and propose a change with a rollback plan.

02Collect Evidence in a Repeatable Order

Start with identity and host context: hostname, operating system version, kernel, uptime, time zone, and who is running the audit. Then review accounts and privilege: UID 0 accounts, users with login shells, sudo group membership, sudo rules, password status, and recent logins. Next, review access paths: SSH configuration, listening sockets, firewall rules, and remote-access services.

Then review the software lifecycle: installed packages, available security updates, repositories, and services enabled at boot. Review logging and monitoring: journal persistence, auditd or equivalent, log forwarding, disk space for logs, and retention. Finally, review file permissions, scheduled jobs, and any unusual setuid binaries or world-writable configuration files.

Save command output to a dated directory. Include the command line, exit status, and timestamp. If a command requires sudo, note that. Do not paste secrets, private keys, password hashes, or full environment variables into a report. Redact sensitive values and preserve only what is needed to support the finding.

baseline-audit.shShell
#!/usr/bin/env bashset -uOUT="audit-$(date +%Y%m%d-%H%M%S)"mkdir -p "$OUT"{  echo "host: $(hostname)"  echo "date: $(date --iso-8601=seconds)"  echo "kernel: $(uname -r)"  echo "os: $(cat /etc/os-release | grep PRETTY_NAME)"  echo "auditor: $(id)"} > "$OUT/context.txt"getent passwd | awk -F: '$3 == 0 {print $1}' > "$OUT/uid0.txt"getent group sudo > "$OUT/sudo-group.txt"sudo -l > "$OUT/sudo-rules.txt" 2>&1ss -tulpn > "$OUT/listening.txt" 2>&1systemctl list-unit-files --state=enabled > "$OUT/enabled-services.txt" 2>&1sudo ufw status verbose > "$OUT/firewall.txt" 2>&1 || trueapt list --upgradable > "$OUT/upgrades.txt" 2>&1 || truefind / -xdev -type f -perm -4000 -print > "$OUT/setuid.txt" 2>/dev/nullls -la /etc/ssh/ > "$OUT/ssh-config.txt" 2>&1echo "Evidence saved to $OUT"

03Turn Observations Into Findings

A finding is not 'SSH is enabled'. A finding is 'SSH permits password authentication for all users, which allows unlimited internet password guessing against this host'. The first is a fact; the second connects the configuration to a threat and an impact. Good findings include evidence, affected scope, likelihood, impact, and a specific recommendation.

Prioritise by risk, not by how interesting the issue is. A missing security header on an internal admin page may be a low finding. A public host with direct root login and password authentication is high. An outdated kernel with a known remotely exploitable vulnerability is critical until proven otherwise. Consider compensating controls: if network access is restricted to a VPN and monitored, the likelihood may be lower, but the exposure still matters.

Separate hard failures from hardening opportunities. Hard failures violate a policy or create a clear path to compromise. Hardening opportunities improve defence in depth but may not be urgent. This distinction keeps the report credible. If everything is critical, nothing is.

04Project Brief: The Baseline Audit Report

Audit one Linux virtual machine you own. Produce a report with an executive summary, scope and method, evidence index, findings, and a 30/60/90-day remediation plan. Include at least eight checks covering identity, access, updates, services, network exposure, logging, file permissions, and backups.

For each finding, state the risk in plain language, include the exact command that produced the evidence, and recommend a fix with a verification command. Redact sensitive values. End with a short section on what you could not verify and why. That honesty is part of professional practice.

A strong report is useful to someone who was not present. It can be rerun, compared with the next audit, and used to track remediation. The goal is not to shame the administrator. The goal is to make the next decision obvious.

audit-report-outline.mdPlain text
# Linux Baseline Audit## Executive summaryOne paragraph on scope, overall risk, and the three most important actions.## Scope and methodHost role, OS version, snapshot name, audit date, commands used.## Findings### F-01: Password authentication enabled for SSH- Risk: high- Evidence: sshd_config PasswordAuthentication yes- Why it matters: internet password guessing and credential stuffing- Recommendation: disable password auth, require keys or a bastion- Verification: ssh -o PreferredAuthentications=password user@host### F-02: Security updates pending- Risk: medium- Evidence: apt list --upgradable output- Recommendation: enable unattended security upgrades and a maintenance window## What could not be verifiedBackup restore, network segmentation, endpoint monitoring.## Remediation planNow: disable SSH password auth, apply critical updates.30 days: enable audit logging and central log forwarding.60 days: add host firewall rules and service inventory.90 days: test restore and repeat the audit.
LET IT CLICK

The ideas worth keeping.

  • A baseline makes hardening repeatable and comparable over time.
  • Collect evidence read-only, with context, timestamps, and redaction.
  • Findings connect configuration to attack path, impact, and verification.
  • Prioritise by exposure and exploitability, not by how interesting a issue feels.
TURN UNDERSTANDING INTO SOMETHING YOU CAN DO

Make it yours.

Type and test your code right here in the interactive workspace. Run your solution, check the output, and compare with the worked guide when ready.

01

Exercise 1: Write a finding from evidence

You observe that /etc/ssh/sshd_config contains 'PermitRootLogin yes' and 'PasswordAuthentication yes' on a host with a public IP. Write a finding with evidence, risk, impact, recommendation, and verification.

Explore a worked solution
one_possible_solution.mdCybersecurity
Finding: SSH permits direct root login and password authentication on a publicly reachable host. Evidence: sudo sshd -T | grep -E 'permitrootlogin|passwordauthentication' returns permitrootlogin yes and passwordauthentication yes. Risk: high. Impact: attackers can attempt unlimited password guessing against the root account, and a successful guess gives full administrative control with no need to escalate. Recommendation: set PermitRootLogin no, create a named administrative account with sudo, disable password authentication, require key-based or SSO access, restrict SSH to a management network, and add rate limiting. Verification: sudo sshd -T after the change, then test from an external network and confirm password login is rejected.

A finding connects configuration to attack path and business impact. Verification proves the fix, not just the intent.

02

Exercise 2: Prioritise three issues

You find (A) a world-readable application log containing email addresses, (B) an outdated web framework with a known remote code execution vulnerability on a public host, and (C) a missing security header on an internal wiki. Rank them and explain your reasoning.

Explore a worked solution
one_possible_solution.mdCybersecurity
B is highest: remote code execution on a public host can lead to full compromise, data theft, and lateral movement. A is next: the log exposes personal data, which may create privacy and regulatory risk, though exploitation requires access to the file or a backup. C is lowest: the missing header is a hardening gap, but the internal wiki has a smaller exposure and no direct compromise path described. Confirm B's version and exploitability, then patch or isolate immediately. Fix A by restricting permissions, rotating any exposed secrets, and reviewing retention. Add C to the hardening backlog.

Priority depends on exposure, exploitability, and impact. A public RCE usually outranks a privacy exposure on a restricted log and a defence-in-depth gap.

A SMALL QUESTION. A USEFUL NEXT STEP.

What stayed with you?

Check the ideas while they’re fresh. Your answers stay in this page and feedback appears as you go.

A LITTLE ACTIVE RECALL0 / 4 answered
01Why should a baseline audit be read-only?
02Which finding is usually the highest risk?
03What should a finding include?
04Why redact hostnames and usernames in a public report?

Keep exploring.

The official references behind this lesson, when you want a second angle or the full details.

MODULE 05 · PRACTICAL SELF-CHECK

Pause. Put the pieces together.

You’ve reached the end of Linux and the Security Command Line. Before moving on, use this task to check what you can do independently.

Produce a before-and-after Linux baseline audit with commands, evidence, verified fixes, and a shell script that re-runs the checks.

Try it in your own environment and write down the result. This is a self-check; reading completion does not evaluate your code.

Review this module

One lesson closer.

Reading is a start. Trying it yourself makes the connection.

Completion is saved in this browser. It records reading and hands-on practice progress.