RousselTMLEARNING

TP · Linux administration: from discovery to expertise

Lab: Analyse logs on the command line

What you will learn in this TP
  • Navigate and inspect files
  • Combine awk, sort and uniq in a pipe
  • Redirect output and archive

Introduction #

What you will learn in this section
  • Navigate and inspect files
  • Combine awk, sort and uniq in a pipe
  • Redirect output and archive

Context. The web team reports intermittent errors. Before installing an analytics tool, you dig into the access log with standard shell tools.

Prerequisites: a disposable Ubuntu 24.04 virtual machine (Multipass, Vagrant or cloud) with a sudo account  ·  Estimated time: 40 min

An error report and a timestamped archive.

Hands-on #

Guided steps, with their solution.

  1. 1. Prepare the workspace

    Why? A realistic dataset lets you practise without touching system logs.

    Create ~/tp-shell/{logs,rapports} and generate 500 nginx-style lines in logs/access.log.
  2. 2. Inspect the file

    Why? Before analysing, check the size, type and line format.

    Show the file size and type, the last 5 lines, then browse it with less searching for 500.
  3. 3. Count HTTP status codes

    Why? The 9th field holds the status code: sort | uniq -c is the universal counting tool.

    Show the number of requests per HTTP code, most frequent first.
  4. 4. Find the error sources

    Why? Filtering before counting answers a precise question.

    List the 5 IP addresses and the URLs producing the most 500 errors, and the total of 4xx and 5xx errors.
  5. 5. Compute the volume served

    Why? awk can sum a column: handy for volumes, durations or amounts.

    Compute the total bytes served (10th field) in kilobytes, then the volume per URL.
  6. 6. Produce and archive a report

    Why? Redirections turn a one-off analysis into a reusable deliverable.

    Write a dated report in rapports/ (HTTP codes and top 500 errors), display it with tee, then archive the folder.
  7. 7. Search the system

    Why? find and grep are the go-to tools to locate a configuration or a large file.

    Find files in /etc mentioning PermitRootLogin, then files over 50 MB on the root partition.

Difficulty level : ●○○○○ (1/5)

My progress

  • ⏱ Estimated time : ≈ 40 min

Sign in to track your progress and take notes. Sign in

💬 Questions about this lesson

No questions yet: be the first to ask for help or share your configuration.

Ask a question about this lesson →

Recommended Articles

Networking on Linux: configuration, diagnosis, firewall and SSH

Configure and troubleshoot Linux networking: ip, ss, netplan and NetworkManager, DNS, layered dia...

Linux administration best practices

Checklist for administering Linux servers: accounts and sudo, SSH, updates, systemd services, sto...

Linux system architecture: kernel, boot and directory tree

Understand how a Linux server works: kernel and user space, the UEFI, GRUB, initramfs and systemd...

Windows networking: IP, DNS, DHCP, firewall and remote access

Configure and troubleshoot Windows networking with PowerShell, deploy a DHCP server, master Windo...

PowerShell for Windows administrators

Master PowerShell to administer Windows: cmdlets and help, object pipeline, filters and formats, ...

Processes, memory and performance: monitoring and troubleshooting a Linux server

Understand and control Linux processes (ps, top, signals, nice, jobs), interpret load, memory and...

Ansible: managing security (Vault, SSH, privileges and secrets)

Securing Ansible: Ansible Vault, SSH key authentication, become and sudo, no_log, hardening the c...

Services, scheduled tasks, event logs and performance

Control Windows services and their recovery, automate with Task Scheduler, use event logs with Ge...

Ansible: the inventory (static, dynamic, groups and variables)

Understand and master the Ansible inventory: INI and YAML files, groups, host and group variables...

Support us

♥ SUPPORT US

Support RousselTM Learning

Courses, articles, labs and certificates stay free with no intrusive ads. A voluntary contribution, of any amount you choose, pays for hosting, lab environments and new content.

Contribute with PayPal Any amount · card or PayPal accountLearn more
QR code PayPal
Or scan this QR code with your phone

Thank you, every contribution counts!