Skip to main content

Settings

Color Mode

Theme Skin

Background

Appearance preferences are saved in this browser only.

Environment

Current Environment Production

Built with JEKYLL_ENV=production. Changes require deployment.

Quick Links

Theme & Build

Jekyll v3.10.0
Last BuildNov 24, 17:25

Page Location

Page Info

Layout default
Collection wargames
Path _wargames/bandit/bandit9.md
URL /wargames/bandit/bandit9/
Date 2026-04-07

Bandit Level 9

Bandit Level 9 — find the only unique line in a file by pairing sort with uniq through a pipe.

Source: This content is aggregated from overthewire (MIT). Visit the original repository for the latest version.

Level Goal

The password for the next level is stored in the file data.txt and is the only line of text that occurs only once

Commands you may need to solve this level

grep, sort, uniq, strings, base64, tr, tar, gzip, bzip2, xxd

Helpful Reading Material

Study guide

Level map: logged in as bandit8, find the password for bandit9.

What this level teaches

Chaining small tools with pipes, and a classic gotcha: uniq only compares neighbouring lines.

Key ideas

  • Pipes. cmd1 | cmd2 feeds the output of the first command to the second, so simple tools combine into powerful ones.
  • sort orders lines so duplicates become adjacent.
  • uniq collapses adjacent duplicate lines; with options it can count them or print only those that occur once.
  • Reading man uniq carefully shows the option you need.

How to approach it

  1. Run uniq on the unsorted file and see why it does not help.
  2. Sort first, then pipe into uniq with the right option.

Why it matters

“Sort, then count unique” is the backbone of countless one-liners, from finding the most frequent IP address in a log to spotting an outlier.