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

The Bash shell and files: navigation, redirections, pipes and text processing

Master the Linux command line: paths, file handling, wildcards, redirections, pipes, searching wi...

Packages, systemd services, logs and scheduled tasks

Install and update software with apt and dnf, manage services with systemctl, write a systemd uni...

Bash scripts for administrators: writing robust scripts

Automate Linux administration with Bash: variables and quoting, conditions, loops, functions, exi...

Ansible: ad-hoc commands

Run immediate actions on a fleet of servers with ansible: the ping, command, shell, copy, apt, se...

Linux vs Unix: the complete guide to commands and distributions

Understand the differences between Linux and Unix, explore distributions (server, desktop, lightw...

Linux server security and hardening

Harden a Linux server: least privilege, updates, secure SSH, firewall, fail2ban, SELinux and AppA...

Backup, monitoring and troubleshooting of a Linux server

Operate a Linux server day to day: 3-2-1 backup strategy with rsync, tar, LVM snapshots and resti...

Users, groups, sudo and permissions on Linux

Manage Linux accounts (useradd, usermod, passwd, chage), groups, sudo and visudo, rwx and octal p...

Storage on Linux: disks, partitions, file systems and LVM

Administer Linux storage: lsblk and blkid, GPT partitioning, ext4 and XFS, mounting and /etc/fsta...

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!