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 |
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."
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.
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)
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]
The password is deliberately hidden — follow the method, you've earned it. 💪
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.
uniq collapses or isolates duplicates among ADJACENT lines only — unsorted input defeats it silentlysort groups every copy of an identical line together, which is why it always comes first in this pipelineuniq -u prints lines with no duplicate at all; plain uniq -d does the opposite, printing only lines that DO repeatDiscuss this writeup with the community on the CTFdojo Discord.
Join the Discord →