The password is the one line in data.txt that occurs exactly once among thousands of duplicated lines — sort groups identical lines together, and uniq -u prints only the ones with no duplicate.
- Platform: OverTheWire Bandit
- Category: Linux Fundamentals
- Level: 8 → 9
- Difficulty: Beginner
- Technique: sort + uniq -u
Challenge description
Level 8 hands you a file where almost every line of text shows up more than once. Somewhere in there is exactly one line that appears only a single time — that line is the password.
"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."
Step 1 — Understand why uniq alone won't work
uniq only collapses consecutive duplicate lines — it has no effect on a file where duplicates are scattered throughout rather than grouped together. The file needs to be sorted first so every copy of a given line ends up adjacent to its other copies.
Step 2 — Sort the file
Sorting brings every duplicate of a line next to each other, which is the precondition uniq needs to do anything useful:
sort data.txt | less (every line now appears grouped with its exact duplicates) Step 3 — Filter to lines with no duplicate
uniq's -u flag prints only the lines that have exactly one occurrence — exactly the property the level described:
sort data.txt | uniq -u [PASSWORD FOR bandit9] 🔑 password intentionally hidden
The password is deliberately hidden — follow the method, you've earned it. 💪
Key takeaways
sort and uniq are almost always used together, because uniq only ever looks at immediately adjacent lines. "Find the duplicate" or "find the one that's NOT duplicated" in a scrambled file is a sort | uniq problem essentially every time.
-
uniqcollapses or isolates duplicates among ADJACENT lines only — unsorted input defeats it silently -
sortgroups every copy of an identical line together, which is why it always comes first in this pipeline -
uniq -uprints lines with no duplicate at all; plainuniq -ddoes the opposite, printing only lines that DO repeat
Originally published on CTFdojo — join the CTFdojo Discord to discuss writeups and get notified about new ones.

![Why Object.keys(user) Returns string[], Not (keyof User)[]: TypeScript Means It](https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F2q4w48b9bzs43tynyhsf.png)