Level 2 → Level 3
Completed📋 Level Information
🎯 Level Goal
The password for the next level is stored in a file called spaces in this filename located in the home directory.
Challenge: The filename contains spaces, which need special handling in the command line.
🔧 Solution Steps
Step 1: Connect to Bandit2
Use the password you obtained from Level 1 to log in:
ssh bandit2@bandit.labs.overthewire.org -p 2220
Step 2: List Files in Home Directory
Check what files are available:
ls
You should see a file named spaces in this filename
Step 3: Read the File (Method 1 - Using Quotes)
The easiest way to handle spaces in filenames is to enclose the entire filename in quotes:
cat "spaces in this filename"
Step 4: Read the File (Method 2 - Escaping Spaces)
Alternatively, you can escape each space with a backslash:
cat spaces\ in\ this\ filename
Step 5: Read the File (Method 3 - Using Tab Completion)
You can also use tab completion to automatically escape the spaces:
cat sp[Tab]
Pressing Tab after typing "sp" will automatically complete and escape the filename.
Step 6: Get the Password
Whichever method you use, the command will output the password for Level 3.
aBZ0W5EmUfAf7kHTQeOwd8bauFJ2lAiG
💡 Explanation
This level teaches you how to handle filenames with special characters (spaces) in Linux.
Why Spaces Cause Problems:
- In Linux command line, spaces are used to separate different arguments
- When you type
cat spaces in this filename, the system interprets it as four separate arguments - It tries to read four different files:
spaces,in,this, andfilename
Solution Methods:
- Quotes: Wrapping the filename in quotes tells the shell to treat everything inside as a single argument
- Escaping: Using backslash before each space tells the shell to treat the space as part of the filename
- Tab Completion: Letting the shell automatically handle the escaping for you
💡 Pro Tips
- Using quotes is generally the safest and most readable method
- Tab completion is the fastest method once you're familiar with it
- You can also use single quotes:
cat 'spaces in this filename' - To see how tab completion works, type
cat spand then press Tab multiple times