Pipes and filters
A radio repeater picked up the same message dozens of times, but interference ruined many copies. Count and sort the lines with a chain of commands to find out which message is the true one.
Lab 7 of 9 in the Linux Fundamentals path. If you get stuck you have 3 hints, from the vaguest to the most precise: they cost 0, 50 and 150 XP.
What you learn
Objectives complete themselves while you work in the terminal; each one is worth experience points:
- Chain two commands with a pipe (|) (80 XP)
- Extract the message column with cut -d -f (120 XP)
- Count the repetitions with sort | uniq -c (150 XP)
Topics: linux, pipe.
Commands you will use
The terminal is simulated and understands about forty Linux commands. In this lab you will mostly need these:
cat: prints the contents of a file: the most direct way to read configurations, notes and logs.cut: extracts one column from each line using a chosen separator, to isolate a specific field of a log.sort: sorts lines, numerically (-n) or in reverse (-r) too.uniq: removes repeated adjacent lines and counts them with -c: together with sort it builds rankings, such as the most insistent addresses.head: shows only the first lines of a file, handy for understanding a log format without reading all of it.base64: encodes and decodes Base64, the format that turns bytes into text. It protects nothing: it can be undone without a key.|: the vertical bar | chains commands: the output of the first becomes the input of the next, so small tools form a complete analysis.
The simulated environment
You work in a simulated Linux shell, in the home folder of the user runner: invented files and folders, no network target.
The defensive lesson
Once the lab is solved, the write-up explains what went wrong and how to protect yourself:
Pipes (|) chain small commands into a pipeline: cut picks the column, sort orders, uniq -c counts, sort -nr ranks, head keeps the top ones. This is how logs are analyzed: for example to find out which IP sends the most requests. Defense: the same pipeline is the quickest tool to notice an attack (one IP with thousands of attempts), so keep your logs and learn to read them.
Before and after this lab
To unlock it you must have solved:
- Finding files (Linux Fundamentals, medium)
After this lab you can move on to:
- Layer upon layer (Encodings & secrets, medium)
- Who keeps pushing? (Blue Team / Defense, medium)
The Linux Fundamentals path
Linux Fundamentals is the starting point. Almost every server, network device and security tool runs on Linux, and anyone who defends a system (or tests it with permission) spends much of their time in a terminal. Here you learn to move around the filesystem, find hidden files, read huge logs piece by piece, search for words with grep, chain commands with pipes and understand permissions, environment variables and history: the basics you will use in every other path.