# CLI-Games — Complete Knowledge Base > This file contains the full content of CLI-Games (https://www.cli-games.com), a browser-based Linux terminal platform with 95+ ASCII games, live CTF cybersecurity competitions, and a social command-line community. ## Games ### 2048 - Command: `2048` - Tags: puzzle, arcade, casual - Description: Sliding tile puzzle game ### Accidental Dragonslayer - Command: `accidental-dragonslayer` - Tags: adventure, dungeon - Description: Sir Turnip faces his greatest challenge yet: an ancient dragon terrorizing the realm. Surely a bumbling knight can defeat such a beast. Right? ### Accidental Emperor - Command: `accidental-emperor` - Tags: adventure, crawler - Description: King Aldric III is dying, and he's got a secret: the kingdom is broke. Sir Turnip must navigate debt, diplomacy, and one very suspicious horse. ### Accidental Knighthood - Command: `accidental-knighthood` - Tags: adventure, dungeon - Description: A humble peasant stumbles into an adventure far beyond their station. Save the princess and earn glory - or meet one of many unfortunate ends. ### Battleship - Command: `battleship` - Tags: strategy, classic, naval, competitive - Description: Naval battle strategy game ### Bureaucratic Nightmare - Command: `bureaucratic-nightmare` - Tags: adventure, dungeon - Description: You've been summoned to the Department of Administrative Affairs. Your goal: obtain Form 27B/6. Good luck. ### Checkers - Command: `checkers` - Tags: strategy, classic, board, competitive - Description: Checkers with AI opponent ### Chess - Command: `chess` - Tags: strategy, classic, board, competitive - Description: Chess with AI opponent or local play ### Connect 4 - Command: `connect4` - Tags: strategy, classic, board, competitive, casual - Description: Classic 4-in-a-row game ### Cron Job - Command: `cronjob` - Tags: puzzle, educational, casual - Description: Write cron expressions from descriptions ### Crossword - Command: `crossword` - Tags: puzzle, word, educational - Description: Tech-themed mini crossword puzzles ### CTF: Capture the Flag - Command: `ctf` - Tags: puzzle, educational, adventure - Description: Master the command line one concept at a time. Graduated puzzles teach navigation, text processing, and shell mastery. ### Dial-Up Days - Command: `dial-up-days` - Tags: adventure, crawler - Description: Lazy summer, small town USA, late 90s. Your homemade botnet has a problem - one of your bots went down. Time to fix it, and maybe expand your network while you're at it. ### Git Gud - Command: `gitgud` - Tags: puzzle, educational, adventure - Description: Escape a git nightmare ### Hackerman - Command: `hackerman` - Tags: puzzle, simulation, adventure - Description: Timed infiltration simulation ### Hangman - Command: `hangman` - Tags: word, classic, casual - Description: Word guessing game ### Mastermind - Command: `mastermind` - Tags: puzzle, classic, strategy - Description: Classic code-breaking logic game ### Minesweeper - Command: `minesweeper` - Tags: puzzle, classic, casual - Description: Classic minesweeper with ASCII graphics ### Pipe Dream - Command: `pipedream` - Tags: puzzle, educational, casual - Description: Transform input to match target via pipeline ### Regex Golf - Command: `regexgolf` - Tags: puzzle, educational, casual - Description: Match A, reject B, fewest chars wins ### Shell Wars - Command: `shellwarz` - Tags: competitive, educational, puzzle - Description: Shell challenges: solo time trial or PvP CTF duel ### Space Crypt - Command: `space-crypt` - Tags: adventure, dungeon - Description: An abandoned space station drifting in the void, its halls filled with mysteries and forgotten technology. Pure exploration - no combat, no resources. Find the escape pod... if you can. ### Station Omega - Command: `station-omega` - Tags: adventure, dungeon - Description: A derelict space station drifts in the void. Your oxygen is limited. Find a way off before you suffocate. ### Sudoku - Command: `sudoku` - Tags: puzzle, classic, casual - Description: Classic Sudoku puzzle ### Sysadmin Tycoon - Command: `sysadmin` - Tags: simulation, casual, educational - Description: IT management sim with ticket queue ### Tavern Dice - Command: `tavern-dice` - Tags: strategy, casual, classic - Description: Push-your-luck dice game with Bohemian rules ### Terminal Poker - Command: `poker` - Tags: strategy, casual, classic - Description: CLI poker vs AI opponents ### The Crypt - Command: `the-crypt` - Tags: adventure, dungeon - Description: A crumbling underground tomb filled with ancient secrets and forgotten treasures. Pure exploration - no combat, no resources. Find the exit... if you can. ### The Vault of Greed - Command: `greed-dungeon` - Tags: adventure, dungeon - Description: A legendary vault filled with treasure. One chance. No return. Requires the Gem of Greed to enter. ### Tic-Tac-Toe - Command: `tictactoe` - Tags: classic, strategy, board, casual - Description: Classic 3x3 grid game ### VM Test Lab - Command: `vm-test-lab` - Tags: adventure, crawler - Description: A small IT company's server room. Your first day on the job, and you need to retrieve an important file from the legacy database. Simple, right? ### Wordie - Command: `wordie` - Tags: word, puzzle, casual - Description: Guess the 5-letter word in 6 tries ## Wiki Articles ### awk - Extract Columns and Transform Text # awk: It's Just Columns You have a file with data in columns. You only want column 3. How hard can that be? Harder than it should be, until you learn awk. ## The One Command You Need ```bash awk '{print $2}' scores.txt ``` That's it. That prints the second column of every line. You see the pattern. `$1` is the first column, `$2` is the second, `$3` is the third. You can go home now, thanks for reading. Still here? Good. Let's go deeper. ## How awk Thinks When awk reads a line, it automatically splits it on whitespace and numbers the pieces. Given this line: ``` alice 2500 gold ``` awk sees: - `$1` = alice - `$2` = 2500 - `$3` = gold - `$0` = the whole line That's the entire mental model. awk splits, you pick which piece you want. ## The Three Patterns That Handle 95% of Real Work **Pattern 1: Print a column** ```bash awk '{print $1}' file.txt ``` **Pattern 2: Print multiple columns** ```bash awk '{print $1, $3}' file.txt ``` The comma adds a space between them. Without the comma, they smash together. **Pattern 3: Different separator (CSV, logs, etc.)** ```bash awk -F, '{print $2}' data.csv ``` The `-F,` tells awk "split on commas, not spaces." Use `-F:` for colons, `-F'\t'` for tabs. That's literally it. It's like the 80/20 rule, but better because it's 95/5. This is where I'd tell you to bookmark this page for reference, but you won't need to. ## Wading into the Weeds with Filtering Want column 2, but only from lines containing "error"? ```bash awk '/error/ {print $2}' log.txt ``` The `/error/` part is a filter. Only matching lines run the `{print}` part. You can combine this with grep knowledge - same regex rules apply. ## Useful Tricks The following are what make awk scary, but you could also flip the script and say they make awk *powerful*. **Print the last column** (when there are too many to count): ```bash awk '{print $NF}' file.txt ``` `NF` means "number of fields." So `$NF` is "the field at position NF" - aka the last one. **Add line numbers**: (when you want awk to count the rows for you) ```bash awk '{print NR, $0}' file.txt ``` `NR` is the current line number. `$0` is the whole line. **Swap column order**: (literally just to confuse your coworker) ```bash awk '{print $2, $1}' file.txt ``` **Uppercase everything**: (WHEN YOU ARE YELLING) ```bash awk '{print toupper($0)}' file.txt ``` ## Real Example: Parsing a Game Leaderboard Say you have `scores.txt`: ``` alice 2500 warrior bob 1800 mage carol 3200 rogue ``` Get just the names: ```bash awk '{print $1}' scores.txt ``` Get names and scores: ```bash awk '{print $1, $2}' scores.txt ``` Find the rogue's score: ```bash awk '/rogue/ {print $2}' scores.txt ``` ## When to Use awk vs Other Tools - **Just searching?** Use grep. - **Simple find/replace?** Use sed. - **Need specific columns?** Use awk. - **Complex transformations?** Still awk, but maybe time for a script. awk and grep are best friends. Grep finds the lines, awk carves them up: ```bash grep "error" log.txt | awk '{print $1, $4}' ``` ## Quick Reference | What you want | Command | |---------------|---------| | First column | `awk '{print $1}' file` | | Last column | `awk '{print $NF}' file` | | Multiple columns | `awk '{print $1, $3}' file` | | CSV column | `awk -F, '{print $2}' file` | | Filter + extract | `awk '/pattern/ {print $2}' file` | | Line numbers | `awk '{print NR, $0}' file` | ## Practice The best way to learn awk is to use it. Try [CTF challenges](/wiki/capture-the-flag) that require parsing log files and extracting data - you'll reach for awk constantly. --- *Yes, the syntax looks like someone's cat walked across the keyboard. But now you know the secret: it's just `print $N` with occasional filters. That's awk.* ### Capture the Flag (CTF) # Capture the Flag (CTF) Capture the Flag is a cybersecurity competition format where participants solve security challenges to find hidden "flags" - secret strings that prove you completed the challenge. ## Origins CTF competitions emerged from the hacker conference scene in the 1990s. [DEFCON](https://defcon.org/), the largest hacker convention in the world, hosted one of the first major CTF events in 1996. What started as informal challenges between friends became a global competitive scene with thousands of teams. ## Competition Formats ### Jeopardy-Style The most common format. Challenges are organized into categories, each worth different point values based on difficulty. Teams work independently to solve as many challenges as possible within the time limit. Common categories: - **Web** - SQL injection, XSS, authentication bypasses - **Crypto** - Breaking or analyzing cryptographic systems - **Pwn** - Binary exploitation, buffer overflows, shellcode - **Reverse Engineering** - Analyzing compiled programs to understand their behavior - **Forensics** - Recovering data from disk images, memory dumps, network captures - **Misc** - Everything else: OSINT, steganography, programming puzzles ### Attack-Defense Teams are given identical servers running vulnerable services. You must simultaneously: - Defend your own services (patch vulnerabilities, monitor for attacks) - Attack other teams' services to capture their flags - Keep your services running (uptime matters) This format mirrors real-world security work more closely but requires more infrastructure to run. ### King of the Hill A single target system. First team to gain access plants their flag. Other teams try to take over and plant their own. The team holding the hill longest wins. ## Skills That Transfer CTF challenges are designed to teach real security concepts: - Reading code and spotting vulnerabilities - Understanding how systems work at a low level - Creative problem-solving under pressure - Research skills - finding the right documentation or prior art - Collaboration and communication with teammates Many professional security researchers, penetration testers, and red teamers got their start in CTF. ## Getting Started ### Online Platforms Several excellent platforms offer CTF-style challenges: - [picoCTF](https://picoctf.org/) - Beginner-friendly, always available, run by Carnegie Mellon - [OverTheWire](https://overthewire.org/wargames/) - Progressive challenges that teach Linux and security basics - [HackTheBox](https://www.hackthebox.com/) - Retired machines and challenges for practice - [TryHackMe](https://tryhackme.com/) - Guided learning paths with hands-on labs ### Live Competitions [CTFtime](https://ctftime.org/) tracks upcoming competitions worldwide. Most are online and free to enter. Start with events rated for beginners before jumping into the competitive scene. ## CTF at CLI-Games CLI-Games offers two ways to train: ### The Skills Tree (Static Training) [CTF: Capture the Flag](/games/ctf) is a structured curriculum that builds from first principles. Navigate procedurally generated filesystems, chain commands together, and hunt for flags hidden in the noise. Tiers progress from Linux literacy through forensics and cryptanalysis. Work at your own pace, save progress, and earn keys as you climb. ### The Range (Live Daily CTF) [The Range](/wiki/the-range) is a live competition that runs daily. Real Linux containers, real attack targets, real-time scoring. Connect from your browser to a personal attack box and compete against other players. Objectives rotate every day. Type `range` or `daily ctf` in the terminal to check if an event is running. Read more about [why we built CTF training this way](/blog/ctf-cli-games-terminal). Want to sharpen other terminal skills? Try [Hackerman](/games/hackerman) for network simulation, [Regex Golf](/games/regexgolf) for pattern matching, or [Sysadmin Simulator](/games/sysadmin) for system administration challenges. ## Further Reading - [CTFtime](https://ctftime.org/) - Competition calendar and team rankings - [CTF Field Guide](https://trailofbits.github.io/ctf/) - Trail of Bits' comprehensive guide - [LiveOverflow](https://www.youtube.com/c/LiveOverflow) - YouTube channel with CTF walkthroughs and explanations - [PentesterLab](https://pentesterlab.com/) - Hands-on web security exercises - [Exploit Education](https://exploit.education/) - Binary exploitation learning platform ### cat - Read Files in the Terminal # cat: See What's in a File You want to see what's in a file. You could open it in an editor. Or: ```bash cat file.txt ``` The entire contents appear in your terminal. That's cat. The name comes from "concatenate" - its original purpose was joining files together. But 99% of the time, you're just using it to read stuff. ## Reading a File ```bash cat readme.txt ``` The whole file, printed to your screen. ## Reading Multiple Files ```bash cat file1.txt file2.txt ``` Both files, one after the other. This is the "concatenate" part. ## Starting a Pipeline cat is often how you feed data into other commands: ```bash cat log.txt | grep "error" ``` Read the file, then filter for errors. ```bash cat data.txt | sort | uniq -c ``` Read the file, then run it through analysis. ## Wildcards ```bash cat *.txt ``` All text files in the current directory, concatenated. ## That's Really It cat is dead simple. It reads files and outputs them. The power comes from what you pipe that output into. ## Quick Reference | What you want | Command | |---------------|---------| | Read a file | `cat file.txt` | | Read multiple files | `cat file1.txt file2.txt` | | All matching files | `cat *.log` | | Start a pipeline | `cat file \| grep pattern` | ## See Also - [head](/wiki/command-head) - just the beginning - [tail](/wiki/command-tail) - just the end - [grep](/wiki/command-grep) - search within ## Practice In [CTF challenges](/wiki/capture-the-flag), `cat flag.txt` is often how the challenge ends. Simple, but satisfying. --- *cat is the "hello world" of file reading. Everyone starts here.* ### Chess at CLI-Games # Bottom Line Up Front If you are looking for bullet games, you won't find them here. Chess via CLI is all about taking it slow. Real games with real opponents are supported via snailmail, but the real training value is in strict SAN input parsing, blindfold puzzles, and vision training. Further explanations of each are below. ## What's Different Here Chess on CLI-Games is no-frills. You don't move pieces with a mouse, you type in the SAN instead. This friction point provides a wealth of training value that your opponents will not have. Making a move in chess is in reality an extremely complex biochemical and neurological process. Slowing down and thinking about each step in that process ensures the links between them are battle tested and rock solid. When you first start out, it will feel like a slog. Good - that is by design. When you start to speed up, when it stops hurting, you will know that your process has been optimized and you will see the efficiency gains over the board. **Puzzles from Lichess** - Thousands of real positions, rated by difficulty. Filter by ELO range, piece count, or both. Multi-move puzzles play through to completion. **Blindfold Mode** - You ever plonk your Queen right into the crosshairs of your opponent's Knight? Of course you have. That's because you failed to maintain a mental model of the board state in your working memory. Blindfold mode addresses this. Start with a small number of pieces - configurable at game start - and gradually work your way up. **Vision Training** - It's just naming letters and numbers, how hard can it be? Thirty seconds on the clock. A square lights up, name it fast. Your final score is correct over attempted. Believe it or not, this is a critical step in achieving whole-board awareness. Optional increased difficulty tiers. ## Daily Puzzle Every day, a new puzzle. Same for everyone. Solve it. Compare times. Brag or suffer in silence. Access it with `daily` from the main terminal. ## Getting Started ``` chess Open the mode selection menu chess -p Jump straight to puzzles chess -pb Blindfold puzzles chess -v Vision trainer chess -1 Play the AI ``` ## Puzzle Filters Dial in exactly what you want to practice: ``` chess -p --elo 800 Easy puzzles chess -p --elo 1500-2000 Intermediate range chess -p --pieces 6 Endgames (few pieces) chess -p --pieces 20-32 Middlegame chaos chess -pb --elo 1200 Blindfold at 1200 level ``` Combine freely. If filters are too restrictive and nothing matches, widen them or try again - puzzle batches vary. ## Vision Trainer Modes Basic mode (30 seconds, no flags) is ranked on leaderboards. Everything else is practice. ``` chess -v Basic - identify squares chess -v --flip Board flips randomly chess -v --moves Mixed piece move questions chess -v --time 60 Longer rounds chess -v --flip --moves Challenge mode ``` ## Volume Tracking Volume is the product of puzzle difficulty and board complexity. Particularly useful for tracking bindfold progression. Try to reach 1 million. Must be signed in to track progress. `Volume = puzzle_rating * pieces_on_board / 100` Check your stats with `stats puzzles`. ## See Also - `man chess` - Full command reference - `daily` - Today's puzzle - `stats puzzles` - Your training history - `leaderboard chess` - Vision trainer rankings ### Chess Opening Principles - Stop Losing in the First 10 Moves # Chess Opening Principles: The 4 Rules That Actually Matter You keep losing games before move 15. Your pieces are tangled. Your king is stuck in the center getting attacked. Meanwhile your opponent's army is coordinated and coming for you. The problem isn't that you don't know the Sicilian Defense. The problem is you're breaking the basic rules that every strong player follows automatically. ## The 4 Principles 1. **Control the center** 2. **Develop your pieces** 3. **Castle early** 4. **Don't move the same piece twice** That's it. Follow these four rules and you'll outplay most beginners without memorizing a single opening line. ## Principle 1: Control the Center The center of the board is e4, d4, e5, d5 - those four squares. Pieces in the center control more squares than pieces on the edge. A knight on e4 attacks 8 squares. A knight on a1 attacks 2. **In practice:** Open with e4 or d4. Put pawns and pieces where they influence the center. Don't shove pawns on the edge while your opponent builds a fortress in the middle. ``` Good first moves: e4, d4, Nf3, c4 Questionable: a4, h4, Na3 ``` ## Principle 2: Develop Your Pieces "Development" means getting pieces off the back rank and into the game. An undeveloped piece is a piece that isn't fighting. **In practice:** Move each piece once before moving any piece twice. Knights before bishops (usually). Get your minor pieces out before your queen. Why not the queen early? Because she'll get chased around by smaller pieces, wasting moves while your opponent develops. ``` Move 1: e4 (pawn) Move 2: Nf3 (knight) Move 3: Bc4 or Bb5 (bishop) Move 4: O-O (castle) ``` Four moves, four different pieces doing something useful. ## Principle 3: Castle Early Castling does two things: tucks your king into a safe corner and connects your rooks. An uncastled king is a target. A castled king lives longer. **In practice:** Aim to castle within the first 10 moves. Don't push the pawns in front of your castled king without good reason - they're his bodyguards. The main reason beginners lose their king: they delayed castling to "do something else" and got caught in the center. ## Principle 4: Don't Move the Same Piece Twice Every move should bring a new piece into the game. If you're shuffling the same knight back and forth, your other pieces are still asleep on the back rank. **The exception:** If there's a tactic (winning material, checkmate threat), break this rule. But if you're just "improving" a piece that's already developed, you're probably wasting time. ## Putting It Together Here's what a principled opening looks like: ``` 1. e4 (control center) 2. Nf3 (develop knight, eye the center) 3. Bc4 (develop bishop, eye f7) 4. O-O (castle, king safe) 5. d3 (support center, open diagonal for bishop) 6. Nc3 (develop last minor piece) ``` Six moves. Every piece except the rooks is active. King is safe. You're ready to play chess. Compare to the beginner trap: ``` 1. e4 2. Qh5 (queen out early) 3. Qxf7+ (grabbed a pawn!) 4. Qf5 (running away) 5. Qg4 (still running) 6. Qg3 (opponent has 5 pieces out, you have 1) ``` You won a pawn. You lost the game. ## Common Beginner Mistakes **Moving pawns instead of pieces:** Pawns can't retreat. Every pawn move weakens something. Develop pieces first. **Bringing the queen out early:** She gets harassed. You lose tempo. Don't. **Ignoring the center:** Playing on the wings while your opponent owns the middle is like fighting with one arm. **Leaving the king uncastled:** "I'll castle next move" until you can't. ## When to Break the Rules These are principles, not laws. Break them when: - There's a tactic (checkmate, winning material) - Your opponent blundered and you must punish immediately - You're following a specific opening line that violates one principle to gain something else But if you're under 1200 ELO, following the rules beats breaking them 90% of the time. ## Practice The best way to internalize these principles is to play games and review them afterward. Ask yourself after each opening: - Did I control the center? - Did I develop all my pieces? - Did I castle? - Did I waste moves? You can practice openings and tactics in our [chess training modes](/wiki/chess-at-cli-games) - puzzles, blindfold training, and vision drills that build the pattern recognition to apply these principles automatically. --- *You don't need to memorize openings. You need to understand why openings work. These four principles are the why.* ### cut - Extract Columns the Simple Way # cut: awk's Simpler Little Sibling You need column 2 from a file. You could use awk. Or you could use cut, which does one thing and does it well: ```bash cut -d' ' -f2 file.txt ``` Second column, space-delimited. Done. ## When to Use cut vs awk - **Just extracting columns?** Use cut. It's simpler. - **Need filtering, math, or logic?** Use [awk](/wiki/command-awk). cut is the tool when you know exactly which field you want and just want it fast. ## The Basic Pattern ```bash cut -d'DELIMITER' -f FIELD file.txt ``` `-d` sets what separates fields. `-f` picks which field(s) you want. ## Common Delimiters **Space-separated:** ```bash cut -d' ' -f1 file.txt ``` **Comma-separated (CSV):** ```bash cut -d',' -f2 data.csv ``` **Colon-separated (like /etc/passwd):** ```bash cut -d':' -f1 /etc/passwd ``` **Tab-separated** (the default, actually): ```bash cut -f1 file.tsv ``` ## Selecting Multiple Fields **Specific fields:** ```bash cut -d',' -f1,3 data.csv ``` Fields 1 and 3. **Range of fields:** ```bash cut -d' ' -f1-3 file.txt ``` Fields 1 through 3. **From field N to end:** ```bash cut -d' ' -f3- file.txt ``` Field 3 and everything after. ## Cutting by Character Position Sometimes you want character positions, not fields: ```bash cut -c1-10 file.txt ``` First 10 characters of each line. ```bash cut -c5 file.txt ``` Just the 5th character. ## Real Examples Get usernames from /etc/passwd: ```bash cut -d':' -f1 /etc/passwd ``` Get the third column of a CSV: ```bash cut -d',' -f3 sales.csv ``` Extract a fixed-width field: ```bash cut -c1-8 log.txt ``` ## Quick Reference | What you want | Command | |---------------|---------| | Field by delimiter | `cut -d',' -f2 file` | | Multiple fields | `cut -d' ' -f1,3 file` | | Field range | `cut -d' ' -f2-4 file` | | Character positions | `cut -c1-10 file` | | Tab-delimited | `cut -f2 file` | ## Practice cut is handy in [CTF challenges](/wiki/capture-the-flag) for quick column extraction when you don't need awk's full power. --- *cut does one thing: extract fields. If that's all you need, it's faster to type than awk.* ### Dial-Up Days: Getting Started # Dial-Up Days A text adventure set in small-town America, late 1990s. ## Setting You're a kid with a pager and a problem. Your homemade network has a node down, and you need to fix it. The town is yours to explore, but be careful—your activities don't go unnoticed. ## Basic Commands Movement uses cardinal directions and contextual pairs: - `north`, `south`, `east`, `west` — street navigation - `in`, `out` — enter and exit buildings - `up`, `down` — stairs and ladders Interaction: - `look` — examine your surroundings - `examine [item]` — inspect something in your inventory - `search` — look for hidden items - `talk [name]` — speak with someone - `use [item]` — interact with objects and terminals - `use pager` — check your device - `sleep` — end the day and rest Freebies: - To run a program, simply point to the .exe (absolute or relative path) - Use `telnet` to remote from bot to bot or `hijack` from your pager - Use `ftp` for large file transfers - Make good use of environment variables (`set`) to manage IP addresses and other information - `clearlogs` to cover your tracks, `eventvwr` to investigate incidents ## Time Each day has 24 moves divided into four phases: morning, afternoon, evening, and night. Some locations are only accessible during certain phases. Sleeping resets your moves and advances to the next day. ## Heat Your actions have consequences. The more attention you draw, the harder things get. Heat decays over time. If it gets too high, you'll have company. ## Tips - Pay attention to what people say - Not everything is as it appears - Some doors only open at certain times - Your pager is your lifeline ### find - Locate Files by Name, Type, or Age # find: Stop Guessing Where You Put That File You know you have a file called `config.json` somewhere. You don't remember where. You could click through folders for ten minutes, or: ```bash find . -name "config.json" ``` There it is. `./src/settings/config.json`. That's find. ## The Basic Pattern ```bash find [where to look] [what to match] ``` The `.` means "current directory and everything under it." Use `/` for the entire system, `~` for your home folder, or any path you want. ## Finding by Name **Exact match:** ```bash find . -name "README.md" ``` **Wildcard:** ```bash find . -name "*.txt" ``` All text files, anywhere in the tree. **Case-insensitive:** ```bash find . -iname "readme.md" ``` Matches README.md, Readme.md, readme.MD, etc. ## Finding by Type **Only files (not directories):** ```bash find . -type f -name "*.log" ``` **Only directories:** ```bash find . -type d -name "test" ``` ## Finding by Time **Modified in the last 7 days:** ```bash find . -mtime -7 ``` **Modified more than 30 days ago:** ```bash find . -mtime +30 ``` Minus means "less than", plus means "more than." ## Finding by Size **Larger than 100MB:** ```bash find . -size +100M ``` **Smaller than 1KB:** ```bash find . -size -1k ``` Suffixes: `c` (bytes), `k` (kilobytes), `M` (megabytes), `G` (gigabytes). ## Limiting Depth Don't want to search forever? ```bash find . -maxdepth 2 -name "*.js" ``` Only goes 2 levels deep. ## Real Examples Find all node_modules folders: ```bash find . -type d -name "node_modules" ``` Find large files hogging space: ```bash find . -type f -size +50M ``` Find old log files: ```bash find /var/log -name "*.log" -mtime +90 ``` ## find vs grep Different tools, different jobs: - **find** searches for files by name, size, date - **grep** searches for text inside files Chain them together: ```bash find . -name "*.log" | xargs grep "error" ``` Find all log files, then search inside them. ## Quick Reference | What you want | Command | |---------------|---------| | By name | `find . -name "file.txt"` | | Wildcard | `find . -name "*.js"` | | Case-insensitive | `find . -iname "readme*"` | | Only files | `find . -type f` | | Only directories | `find . -type d` | | Recent files | `find . -mtime -7` | | Large files | `find . -size +100M` | | Limit depth | `find . -maxdepth 2` | ## Practice find is essential in [CTF challenges](/wiki/capture-the-flag) where flags hide in unexpected places. Master find and nothing stays hidden for long. --- *Yes, find has a hundred flags. You need five. The ones above cover 95% of real searching.* ### grep - Search for Text in Files # grep: Find the Needle in the Haystack You have a 10,000 line log file. Somewhere in there is the word "error." Good luck scrolling. Or: ```bash grep "error" log.txt ``` Every line containing "error" appears. Everything else vanishes. That's grep. ## The Basic Pattern ```bash grep "pattern" file.txt ``` grep prints every line that contains your pattern. Simple as that. ## The Flags You'll Actually Use **Case-insensitive:** ```bash grep -i "error" log.txt ``` Matches "error", "Error", "ERROR", whatever. **Show line numbers:** ```bash grep -n "error" log.txt ``` Now you know it's on line 847. **Invert match (lines that DON'T match):** ```bash grep -v "DEBUG" log.txt ``` Filters out all the debug noise. **Count matches:** ```bash grep -c "error" log.txt ``` Just the number. "You have 47 errors. Good luck." **Context around matches:** ```bash grep -A 2 "error" log.txt # 2 lines After grep -B 2 "error" log.txt # 2 lines Before grep -C 2 "error" log.txt # 2 lines of Context (both) ``` See what happened around the error. ## grep + Regex grep understands regular expressions: ```bash grep "^error" log.txt # Lines starting with "error" grep "error$" log.txt # Lines ending with "error" grep "err.r" log.txt # . matches any character grep -E "error|warning" log.txt # error OR warning ``` The `-E` flag enables extended regex - more features, less escaping. ## Searching Multiple Files ```bash grep "TODO" *.js # All .js files here grep -r "TODO" src/ # Recursive through src/ ``` The `-r` flag searches directories recursively. ## grep in Pipelines grep is often the first filter in a chain: ```bash cat log.txt | grep "error" | awk '{print $1}' ``` Find errors, then extract the first column. Or filter any command's output: ```bash ps aux | grep "node" ``` ## Quick Reference | What you want | Command | |---------------|---------| | Basic search | `grep "pattern" file` | | Case-insensitive | `grep -i "pattern" file` | | Line numbers | `grep -n "pattern" file` | | Invert match | `grep -v "pattern" file` | | Count matches | `grep -c "pattern" file` | | Context | `grep -C 3 "pattern" file` | | Recursive | `grep -r "pattern" dir/` | | OR patterns | `grep -E "this\|that" file` | ## Practice grep is your constant companion in [CTF challenges](/wiki/capture-the-flag). Log analysis, config hunting, flag extraction - it all starts with grep. --- *If you learn one command from this wiki, make it grep. It's the flashlight you'll reach for every single time.* ### head - See the First Lines # head: Just Show Me the Beginning You have a huge file. You don't want to see all 50,000 lines. You just want a preview: ```bash head log.txt ``` First 10 lines. Quick peek. That's head. ## Specifying How Many Lines **First 5 lines:** ```bash head -n 5 file.txt ``` **First 20 lines:** ```bash head -n 20 file.txt ``` Or the shorthand: ```bash head -5 file.txt head -20 file.txt ``` ## In Pipelines head is commonly used to limit output from other commands: **Top 10 most frequent items:** ```bash sort data.txt | uniq -c | sort -rn | head ``` **First 5 matches:** ```bash grep "error" log.txt | head -5 ``` ## Just the First Line ```bash head -n 1 file.txt ``` Useful for grabbing headers or checking file format. ## Multiple Files ```bash head file1.txt file2.txt ``` Shows the first 10 lines of each, with headers separating them. ## Quick Reference | What you want | Command | |---------------|---------| | First 10 lines | `head file` | | First N lines | `head -n N file` or `head -N file` | | Limit pipe output | `command \| head` | | Just first line | `head -n 1 file` | ## See Also - [tail](/wiki/command-tail) - the opposite (end of file) - [cat](/wiki/command-cat) - whole file ## Practice In [CTF challenges](/wiki/capture-the-flag), head helps you preview large files quickly and grab just the top results from sorted data. --- *head is for peeking. When you don't need the whole thing, just ask for the top.* ### sed - Find and Replace from the Command Line # sed: Find and Replace Without Opening a File You need to replace "foo" with "bar" in a file. You could open it in an editor, Ctrl+H, type both strings, click replace all, save, close. Or: ```bash sed 's/foo/bar/g' file.txt ``` Done. No editor, no clicking, no saving. That's sed. ## The One Pattern You Need ```bash sed 's/old/new/g' file.txt ``` That's the whole thing. `s` means substitute. `old` is what you're replacing. `new` is what you're replacing it with. `g` means "all occurrences" (without it, sed only replaces the first match per line). The slashes are just delimiters - they separate the parts. ## How sed Thinks sed reads each line, applies your rules, and prints the result. It doesn't modify the original file by default - it just outputs the transformed text. Want to actually change the file? Add `-i`: ```bash sed -i 's/old/new/g' file.txt ``` Now the file itself is modified. Use with care. ## Common Patterns **Replace text everywhere:** ```bash sed 's/error/warning/g' log.txt ``` **Delete lines containing a pattern:** ```bash sed '/DEBUG/d' log.txt ``` The `d` command deletes matching lines entirely. **Replace only on matching lines:** ```bash sed '/header/s/old/new/g' file.txt ``` Only runs the substitution on lines containing "header". **Delete blank lines:** ```bash sed '/^$/d' file.txt ``` `^$` is regex for "start followed immediately by end" - an empty line. You'd know that if you were keeping up with your Regexgolf. **Case-insensitive replace:** ```bash sed 's/error/warning/gi' file.txt ``` The `i` flag ignores case. ## The Delimiter Trick Slashes are traditional, but they're annoying when your text contains slashes: ```bash sed 's/\/path\/to\/file/\/new\/path/g' # ugly escape hell sed 's|/path/to/file|/new/path|g' # clean ``` You can use any character as the delimiter. Pipes `|`, colons `:`, and `#` are popular alternatives. ## Real Example: Repurposing a Cover Letter (don't do this) Switching the name: ```bash sed -i 's/companyA/companyB/g' cover_letter.txt ``` Capitalizing a name that is also a word: ```bash sed -i 's/Mrs\. will/Mrs. Will/' cover_letter.txt ``` The `Mrs\.` makes sure you only replace instances referring to the person, not the verb. ## sed vs Other Tools - **Interactive editing?** Use your editor. - **Just searching?** Use grep. - **Need columns?** Use awk. - **Find and replace?** That's sed. sed shines in scripts and pipelines where you can't open an editor. It's also faster than any GUI for bulk changes. ## Quick Reference | What you want | Command | |---------------|---------| | Replace all | `sed 's/old/new/g' file` | | Replace in-place | `sed -i 's/old/new/g' file` | | Delete lines | `sed '/pattern/d' file` | | Delete blank lines | `sed '/^$/d' file` | | Case-insensitive | `sed 's/old/new/gi' file` | | Different delimiter | `sed 's|old|new|g' file` | ## Practice sed is essential for [CTF challenges](/wiki/capture-the-flag) where you need to transform data formats or clean up output for the next command in a pipeline. --- *Three slashes and a letter. That's sed. `s/this/that/g` and you're done.* ### sort - Put Lines in Order # sort: Bring Order to Chaos You have a file with data in random order. You want it sorted. That's literally what sort does: ```bash sort names.txt ``` Alphabetical order. Done. ## Alphabetical vs Numerical Here's where people get tripped up. By default, sort orders alphabetically: ``` 1 10 2 3 ``` That's "correct" alphabetically (1 comes before 2, and 10 starts with 1). But if you want numerical order: ```bash sort -n numbers.txt ``` Now you get 1, 2, 3, 10. ## Reverse Order ```bash sort -r file.txt ``` Z to A, or highest to lowest with `-rn`. ## Sorting by Column Real data has multiple columns. Sort by the second one: ```bash sort -k2 data.txt ``` Sort by the third column numerically: ```bash sort -k3 -n scores.txt ``` ## Custom Delimiters If your columns aren't space-separated: ```bash sort -t',' -k2 data.csv ``` The `-t','` sets comma as the delimiter. ## Remove Duplicates While Sorting ```bash sort -u file.txt ``` Like `sort | uniq` but in one command. ## The Classic Pipeline This pattern appears everywhere: ```bash cat data.txt | sort | uniq -c | sort -rn | head ``` Read → sort → count duplicates → sort by count → show top results. It answers "what are the most common items?" ## Real Examples Sort a leaderboard by score (highest first): ```bash sort -k2 -rn scores.txt ``` Sort /etc/passwd by user ID: ```bash sort -t':' -k3 -n /etc/passwd ``` Find most frequent log entries: ```bash cat access.log | sort | uniq -c | sort -rn | head -10 ``` ## Quick Reference | What you want | Command | |---------------|---------| | Alphabetical | `sort file` | | Numerical | `sort -n file` | | Reverse | `sort -r file` | | By column | `sort -k2 file` | | Numeric by column | `sort -k2 -n file` | | With delimiter | `sort -t',' -k2 file` | | Unique only | `sort -u file` | ## Practice sort is fundamental in [CTF challenges](/wiki/capture-the-flag) for frequency analysis and organizing data for the next step in your pipeline. --- *sort is the setup for everything else. Once your data is in order, patterns emerge.* ### tail - See the Last Lines # tail: Show Me the End You have a log file that's been collecting data for months. You only care about the most recent entries: ```bash tail log.txt ``` Last 10 lines. The freshest data. That's tail. ## Specifying How Many Lines **Last 5 lines:** ```bash tail -n 5 file.txt ``` **Last 50 lines:** ```bash tail -n 50 file.txt ``` Or shorthand: ```bash tail -5 file.txt tail -50 file.txt ``` ## Skip the Header Here's a trick: `tail -n +2` means "from line 2 onward" - effectively skipping the header: ```bash tail -n +2 data.csv ``` All data except the first line. Useful for CSVs with headers. ## In Pipelines **Bottom 10 results after sorting:** ```bash sort -n scores.txt | tail ``` **Last few errors:** ```bash grep "error" log.txt | tail -5 ``` ## Just the Last Line ```bash tail -n 1 file.txt ``` Sometimes that's all you need. ## Quick Reference | What you want | Command | |---------------|---------| | Last 10 lines | `tail file` | | Last N lines | `tail -n N file` or `tail -N file` | | Skip first line | `tail -n +2 file` | | Just last line | `tail -n 1 file` | ## See Also - [head](/wiki/command-head) - the opposite (beginning of file) - [cat](/wiki/command-cat) - whole file ## Practice In [CTF challenges](/wiki/capture-the-flag), tail helps you check recent log entries and grab the lowest values from sorted data. --- *tail is for recency. When you want the latest, look at the end.* ### The Accidental Series # The Accidental Series CLI-Games' flagship text adventure franchise. Terry Pratchett meets Monty Python in a world where turnips solve impossible problems and a peasant keeps accidentally becoming important. ## The Story So Far You are Sir Turnip of Mudbury. Twenty-three years of farming root vegetables, then fate intervened. **Accidental Knighthood:** Princess kidnapped. You stumbled into the rescue. King knighted you out of gratitude (and possibly embarrassment). Now you're a knight. You don't know how swords work. **Accidental Dragonslayer:** Ancient dragon terrorizing the realm. Previous heroes failed. King sent you because everyone else is dead or hiding. You brought turnips. **Accidental Emperor:** King's dying. Kingdom's broke. Conquest seems like the only option. Unless a turnip farmer can find another way. ## How It Plays Text adventure. Type commands. Make choices. Die repeatedly until you figure it out. - `north`, `south`, `east`, `west` - move around - `look` - examine surroundings - `take [item]` - pick stuff up - `use [item]` - interact with things - `talk [name]` - speak to characters - `inventory` - check your pockets - `help` - see all commands Multiple endings per crawler. Some heroic. Some tragic. Some involve becoming best friends with a dragon. ## The Gem of Greed Hidden across the series are three gem shards. Grandmother's gift. A forgotten place. A moment of triumph. Find them all. Something ancient awaits. ## Characters Worth Knowing **Old Marge** - Mudbury turnip vendor. Always there. Knows more than she lets on. "Turnips solve everything." **Princess Elara** - Not a damsel. Partners with you by the third game. Growing into a leader. **King Aldric III** - Magnificent beard. Shinier crown. Pragmatic about sending turnip farmers on suicide missions. **Scorchlox the Eternal** - Ancient red dragon. Terrifying. Lonely. Surprisingly open to conversation if you survive long enough to have one. ## Tips - Turnips are never just turnips - Death is a teacher, not a failure state - Talk to everyone twice - Items persist across playthroughs - what you find stays with you - The hermit sees more than he says ## Unlock Requirements **Accidental Knighthood** - Available to all **Accidental Dragonslayer** - Complete Knighthood (any ending) **Accidental Emperor** - Complete both previous games, earn 50%+ of combined badges ## See Also - `man accidental-knighthood` - Game manual - `man accidental-dragonslayer` - Game manual - `man accidental-emperor` - Game manual ### The Network # The Network Welcome to the CLI-Games network. When you log in, you're provisioned a permanent IP address and choose your hostname. You'll also get access to networking commands that help you build your social graph. There is no "friend" button — you open your firewall and decide what to share. All registered players are reachable hosts on 10.10.0.0/16 and you interact through your terminal. Guests are provisioned a temporary IP on the 192.168.0.0/24 subnet, scoped to a single browser tab. Until you authenticate, you can use a limited set of network commands — `ifconfig`, `ip`, `ping`, `whois`, and `traceroute` — and play non-rated games. For everything else, you'll need an account. This page covers the foundation: who you are on the network, how you find others, and how you control who can reach you. Everything else — communication, friends, challenges, crews — builds on top of this. ## Your Machine When you sign up, you're assigned a permanent network identity. This is how the network fabric ensures players can find each other and verify one another's identity. - Your IP address (10.10.x.y), hostname, and MAC address - `ifconfig` and `ip addr` to inspect your interfaces - Network config lives where you'd expect it: `/etc/hostname`, `/etc/hosts`, `/etc/resolv.conf` - `/etc/motd` — the message visitors see when they SSH into your machine - Your home directory with `.bashrc`, `.profile`, aliases, and a customizable PS1 - A web server you can customize with HTML and open for all to see on port 80 ## Firewall & Privacy The first thing you'll want to get straight is your security posture. By default, your firewall is permissive — you're discoverable and reachable on all ports. If you don't want strangers messaging you or dropping into live chat, lock those ports down: - `ufw deny from any to any port 25` - `ufw deny from any to any port 517` Here are some more examples. For a full list, run `man ufw`: - `ufw status` — See your current rules and default policy - `ufw allow/deny from [to any port ]` — Control access per-player and per-port - `ufw default deny incoming` — Go dark. Block everything unless explicitly allowed - `ufw enable/disable/reset` — Master switch and factory reset ### Shorthand Commands Some social commands are packaged firewall operations. The dual-write goes both ways — `ufw allow` creates a friendship, and accepting a friend request creates an allow rule: | Command | Equivalent UFW Operation | |---------|--------------------------| | `friend accept alice` | `ufw allow from alice` | | `friend block alice` | `ufw deny from alice` | | `friend remove alice` | `ufw delete allow from alice` | | `incognito on` | `ufw default deny incoming` | | `incognito off` | `ufw default allow incoming` | Note that `friend add` only sends a request — no firewall rule is created until the other player accepts. The `ufw allow` command skips the request and opens access immediately (and creates the friendship as a side effect). ### Port Mapping Each port maps to a social feature. Blocking a port disables that interaction for anyone not explicitly allowed: | Port | Service | What It Controls | |------|---------|-----------------| | 8 | ICMP | Online status visibility (`ping`) | | 22 | SSH | Terminal visits to your home directory | | 25 | SMTP | Direct messages | | 80 | HTTP | Your homepage (`curl player:80`) | | 443 | HTTPS | Game challenges | | 517 | Talk | Live 1:1 chat | | 5900 | VNC | Remote viewing | | 6667 | IRC | Chat room participation | | 8080 | Alt-HTTP | Trading | Omitting the port from a rule applies it to all services. `netstat -tlnp` or `ss -tlnp` will show what you're exposing. Firewall rules are enforced server-side — there's no way to bypass them from the client. ### Incognito & Multiplayer `incognito on` sets your default firewall policy to deny, which makes you invisible to pings, scans, and directory listings. But what happens when you join a live game or event with strangers? Your IP is still your IP — it doesn't change and it won't be faked. During a live session, opponents can see you in the game. However, your username displays as `anonymous` on leaderboards, activity feeds, and event results. If an opponent grabs your IP and tries to `ping` or `ssh` it after the match, they'll get nothing back — the firewall is still up. The address is real, but it's a dead end. Existing friends bypass incognito. If someone already has a `ufw allow` rule for you, they can still reach you normally. ## Directory Permissions Consider your home directory's permissions. Out of the box, the following directories are set to 700 (owner-only): - `inbox/` - `archive/` - `sandbox/` This matters because when someone SSHs into your terminal, they can poke around your filesystem. Be careful who you let in, and make sure your permissions are what you want them to be. ## Customization Control what others see when they interact with your machine. ### MOTD Banner The MOTD is a plain text file at `/etc/motd`. Write whatever you want to it. When someone SSHs into your machine, they'll see it first thing. - `cat /etc/motd` — see the default banner - `echo "Welcome to my machine." > /etc/motd` — replace it - `cat /etc/motd` — see that it changed ### Web Server Edit `~/public/index.html` to customize your homepage. `curl localhost:80` to see it render. If you miss when the internet was nothing but plain HTML tags, this is for you. ### Guest Book This one doesn't come pre-configured, but you can create a world-writable file on your home directory, allowing anyone who visits to leave a note. Back it up to your archive often. Try: - `echo "Welcome! Please sign the guestbook." > guestbook.txt` - `chmod 777 guestbook.txt` ## Discovery How you find other players on the network: - `ping ` — Check if a host is online. Respects firewall rules on port 8. - `nmap ` — Port scan a host or sweep a subnet. Supports `-sV` for service versions and `-p` for specific ports. CIDR scans return up to 256 results. Players with default deny appear as "Host seems down." Every scan leaves a footprint in the target's `/var/log/auth.log`. - `arp -a` — Your recent contacts cache. Successful pings and scans update it. - `dig`, `nslookup`, `host` — DNS resolution between hostnames and IPs. Reverse lookups work too. - `whois ` — Registration info: username, IP, signup date, founder number, crew tag, game ratings. - `who` / `w` — See who's currently online, their status, and what they're doing. ## See Also - [Communication](/wiki/communication) — talk, ssh, curl, and messaging - [IRC](/wiki/irc) — Chat rooms, tiers, and reputation - [Friends & Challenges](/wiki/friends-and-challenges) — Relationships and competitive play - [Profile, Reputation & Leaderboards](/wiki/profile-reputation-leaderboards) — Identity and rankings - [Collectibles & Economy](/wiki/collectibles-and-economy) — Keys, trading, and crafting - [Crews](/wiki/crews) — Guilds and crew leaderboards ### tr - Translate and Transform Characters # tr: The Character Translator You need to convert a file to uppercase. Or delete all the digits. Or decode ROT13. tr does all of this by translating characters from one set to another. ```bash echo "hello" | tr 'a-z' 'A-Z' ``` Output: `HELLO`. That's tr. ## The Basic Pattern ```bash tr 'SET1' 'SET2' ``` Every character in SET1 becomes the corresponding character in SET2. `a` becomes `A`, `b` becomes `B`, and so on. **Important:** tr reads from stdin only. You always pipe into it. ## Case Conversion **Lowercase to uppercase:** ```bash cat file.txt | tr 'a-z' 'A-Z' ``` **Uppercase to lowercase:** ```bash cat file.txt | tr 'A-Z' 'a-z' ``` ## Deleting Characters Use `-d` to delete instead of translate: **Remove all digits:** ```bash echo "abc123def" | tr -d '0-9' ``` Output: `abcdef` **Remove newlines:** ```bash cat file.txt | tr -d '\n' ``` Everything becomes one line. **Remove all non-letters:** ```bash echo "Hello, World! 123" | tr -d '[:punct:][:digit:][:space:]' ``` Output: `HelloWorld` ## Squeezing Repeated Characters Use `-s` to collapse repeated characters: **Multiple spaces to single space:** ```bash echo "too many spaces" | tr -s ' ' ``` Output: `too many spaces` ## ROT13 (The Classic) ROT13 is a simple cipher that rotates letters by 13 positions: ```bash echo "secret message" | tr 'a-zA-Z' 'n-za-mN-ZA-M' ``` Run it again to decode - ROT13 is its own inverse. ## Character Classes tr understands these shortcuts: | Class | Meaning | |-------|---------| | `a-z` | Lowercase letters | | `A-Z` | Uppercase letters | | `0-9` | Digits | | `[:lower:]` | Lowercase letters | | `[:upper:]` | Uppercase letters | | `[:digit:]` | Digits | | `[:space:]` | Whitespace | | `[:punct:]` | Punctuation | ## Real Examples Normalize whitespace in messy data: ```bash cat data.txt | tr -s ' \t' ' ' ``` Remove carriage returns (Windows line endings): ```bash cat file.txt | tr -d '\r' ``` Simple substitution cipher: ```bash echo "hello" | tr 'a-z' 'zyxwvutsrqponmlkjihgfedcba' ``` ## Quick Reference | What you want | Command | |---------------|---------| | Uppercase | `tr 'a-z' 'A-Z'` | | Lowercase | `tr 'A-Z' 'a-z'` | | Delete chars | `tr -d '0-9'` | | Squeeze repeats | `tr -s ' '` | | ROT13 | `tr 'a-zA-Z' 'n-za-mN-ZA-M'` | ## Practice tr is surprisingly useful in [CTF challenges](/wiki/capture-the-flag), especially for decoding simple ciphers and cleaning up data. --- *tr is the underrated workhorse. Anytime you're doing character-level transforms, it's faster than sed and simpler than awk.* ### uniq - Count and Remove Duplicates # uniq: Find What Repeats You want to know what appears most often in a file. Or remove duplicate lines. Or find lines that only appear once. That's uniq. But here's the catch: **uniq only catches adjacent duplicates.** If duplicates aren't next to each other, uniq won't see them. That's why uniq almost always comes after sort. ## The Golden Pattern ```bash sort file.txt | uniq ``` Sort first, then uniq. This removes all duplicates. ## Counting Occurrences This is uniq's killer feature: ```bash sort file.txt | uniq -c ``` Output: ``` 3 apple 1 banana 5 cherry ``` Now you know cherry appears 5 times. ## The Full Frequency Analysis Pipeline ```bash sort file.txt | uniq -c | sort -rn ``` 1. Sort (so duplicates are adjacent) 2. Count duplicates 3. Sort by count, highest first This answers "what are the most common items?" in any dataset. ## Only Show Duplicates ```bash sort file.txt | uniq -d ``` Lines that appear more than once. ## Only Show Unique Lines ```bash sort file.txt | uniq -u ``` Lines that appear exactly once. ## Case-Insensitive ```bash sort -f file.txt | uniq -i ``` "Apple" and "apple" count as the same. ## Real Examples Most common IP addresses in a log: ```bash awk '{print $1}' access.log | sort | uniq -c | sort -rn | head ``` Find duplicate entries: ```bash sort names.txt | uniq -d ``` Find entries that appear exactly once: ```bash sort data.txt | uniq -u ``` ## Why Sort First? uniq compares each line to the one before it. Given this unsorted input: ``` apple banana apple ``` uniq sees "apple", then "banana" (different!), then "apple" (different from banana!). It won't catch that apple appears twice. After sorting: ``` apple apple banana ``` Now uniq sees the duplicate. ## Quick Reference | What you want | Command | |---------------|---------| | Remove duplicates | `sort file \| uniq` | | Count occurrences | `sort file \| uniq -c` | | Top frequencies | `sort file \| uniq -c \| sort -rn` | | Only duplicates | `sort file \| uniq -d` | | Only unique | `sort file \| uniq -u` | ## Practice uniq is essential in [CTF challenges](/wiki/capture-the-flag) for frequency analysis - cracking simple ciphers, finding patterns in data, identifying anomalies. --- *Remember: sort first, then uniq. They're a package deal.* ### wc - Count Lines, Words, and Characters # wc: Count Things How many lines in this file? How many words? wc tells you: ```bash wc file.txt ``` Output: ` 42 156 1089 file.txt` That's 42 lines, 156 words, 1089 bytes. Simple stats. ## Getting Specific Usually you just want one number: **Lines only:** ```bash wc -l file.txt ``` **Words only:** ```bash wc -w file.txt ``` **Bytes/characters only:** ```bash wc -c file.txt ``` ## The -l Flag Lives at the End of Pipelines This is wc's most common use - counting how many results came through: **How many errors?** ```bash grep "error" log.txt | wc -l ``` **How many files match?** ```bash find . -name "*.txt" | wc -l ``` **How many unique entries?** ```bash sort data.txt | uniq | wc -l ``` ## Multiple Files ```bash wc *.txt ``` Shows stats for each file, plus a total. ## Quick Reference | What you want | Command | |---------------|---------| | All stats | `wc file` | | Line count | `wc -l file` | | Word count | `wc -w file` | | Byte count | `wc -c file` | | Count pipe results | `command \| wc -l` | ## Practice In [CTF challenges](/wiki/capture-the-flag), `wc -l` is your sanity check. "Did my grep find anything?" "How many files am I dealing with?" --- *wc is the simplest possible question: how many?* ### Wordie # Wordie Five letters. Six tries. You know the drill. ## The Game Guess the hidden word. Each guess tells you what you got right: - **Green** `[G]` - Right letter, right spot - **Yellow** `[Y]` - Right letter, wrong spot - **Gray** `[ ]` - Letter not in the word Type your guess. Hit enter. Repeat until you solve it or run out of tries. ## Daily Challenge Same word for everyone, every day. Complete it to build your streak. Miss a day? Streak resets. No mercy. ``` daily Play today's challenge from main terminal wordie daily Jump straight to it from the game ``` ## Hard Mode For people who think the regular game is too easy. When hard mode is on: - Green letters must stay in their positions - Yellow letters must appear somewhere in your guess No more fishing with throwaway words. Every guess counts. Toggle with `hard` in-game. ## Timed Mode Set a time limit. Race yourself. ``` timed 60 60 seconds per game timed 30 30 seconds (sweaty) timed off Back to relaxed ``` ## Strategy The classic opener debate: CRANE vs SLATE vs ADIEU vs ROATE. Pick one. Stick with it. Or don't - we're not your mom. What matters: - Cover common letters early - Pay attention to yellows - position matters - Gray letters are information too - Hard mode forces better habits ## Why Play Here No cookie banners. No ads. No social media buttons begging for engagement. Just type `wordie` and play. The way word games should be. ## Sharing Solved it? Brag about it. ``` share Copy result grid to clipboard ``` The colored grid format everyone recognizes. Paste wherever. ## See Also - `man wordie` - Full command reference - `daily` - Today's puzzle - `stats` - Your play history ## FAQ ### What is CLI-Games? CLI-Games is a browser-based terminal that lets you play classic games like Chess, Minesweeper, and Sudoku entirely through text commands. It recreates the experience of using a Linux command line, complete with ASCII graphics and keyboard-only controls. ### Do I need to download anything? No. CLI-Games runs entirely in your browser. Just visit the site and start typing commands. No installation, no plugins, no app store. ### Is CLI-Games free? Yes. All games are free to play. We may add optional premium features in the future, but the core experience will always be free. ### Do I need an account? No account is required to play. However, creating a free account lets you save your progress, track statistics, compete on leaderboards, and play online multiplayer games. ### How do I start playing? Type 'games' to see all available games, then type the game name to start playing. For example, type 'chess' to play chess, or 'minesweeper' to play minesweeper. Type 'help' anytime for assistance. ### What commands are available? Type 'help' to see all available commands. Common commands include 'games' (list games), 'save' (save progress), 'load' (load a save), 'stats' (view your statistics), and 'quit' (exit current game). ### Can I play on mobile? Yes, CLI-Games works on mobile browsers. The experience is optimized for keyboard input, but you can use the on-screen keyboard on mobile devices. ### How do I save my game? While playing, type 'save myname' to save your progress (replace 'myname' with any name you choose). Later, start the game with that save name to resume: 'chess myname'. You need an account to save games. ### What are dungeon crawlers? Dungeon crawlers are text adventure games where you explore locations, interact with characters, and solve puzzles by typing commands. Try 'accidental-knighthood' for a comedic medieval adventure or 'dial-up-days' for a 90s hacker story. ### How do leaderboards work? Leaderboards track high scores for each game. Your best score is recorded when you complete a game. Leaderboards show the top players globally and among your friends. ### Is my data private? Yes. We only store what's necessary: your username, email (for account recovery), and game progress. We don't sell data or use invasive tracking. See our privacy policy for details. ### How do I report a bug? Use the 'feedback' command in the terminal, or email us directly. We appreciate bug reports and actively fix issues. ## Blog Posts ### CTF Training with No Downloads, No Logins, No Latency, and No Paywalls (2026-02-21) Cybersecurity training and competition should be free and frictionless. Introducing: the containerette — the brand new invention that makes it possible. Tags: ctf, security, training, free, education, open-access ### The Range is Live: Daily CTF on Real Infrastructure (2026-02-16) The transition to a reputable CTF platform has taken a major step over the weekend by bringing online a live, daily, shared vulnerable target for users to poke at. Tags: ctf, range, competition, security, launch ### Wire Report #2: They Gifted Us Some Malware to Decompile (2026-02-14) Our honeypot captured 16 malware samples in one week. We unpacked, decompiled, and reverse-engineered them. Here's what's inside three active botnets — and what their source code reveals about how attacks actually work. Tags: security, honeypot, wire, ctf, reverse-engineering, malware ### Wire Report #1: What 6,000 Attackers Tried in 24 Hours (2026-02-08) We pointed a server at the internet and watched. In 24 hours, 297 unique IPs launched 6,625 connection attempts. Here's what they tried, what they were after, and what you can learn from it. Tags: security, honeypot, wire, ctf, education ### Meet Clide, the Deliberately Unhelpful AI Assistant (2026-02-02) Most AI assistants are eager to help. Clide isn't. Here's why that's the point. Tags: clide, ai, philosophy, features ### Capture the Flag (CTF) in the CLI-Games Terminal (2026-02-01) Too many people try to jump straight into complex exploits and big competitions without first becoming comfortable at the command line. Our system builds from first principles to ensure a rock solid foundation before adding complexity. Mastering the overlooked basics will be your CTF secret weapon. Tags: ctf, security, terminal, philosophy ## Platform Overview CLI-Games is a browser-based Linux terminal platform at https://www.cli-games.com. ### Key Features - 95+ ASCII games playable through typed commands - Live CTF cybersecurity competitions (The Range) - 27 structured CTF training scenarios across 14 skill modules - PvP multiplayer (chess, checkers, battleship) - IRC-style chat rooms - Rolling 30-day leaderboards - Public player profiles with badges and stats - Daily challenges (chess puzzles, wordie, CTF rotations) - Clide AI in-terminal assistant - Virtual player network (IP addresses, firewalls, discovery tools) - Command reference wiki - Technical blog ### Audience - Linux enthusiasts who want nostalgic terminal gaming - Beginners learning the command line through play - Cybersecurity students practicing CTF skills - Casual gamers who enjoy text-based and retro games ### Access - URL: https://www.cli-games.com - Free, browser-based, no download required - Optional account for saving progress and leaderboards