The password for the next level is stored in a file called spaces in this filename located in the home directory. The challenge here is dealing with spaces in filenames, which require special handling in the command line.
cat- Display file contentsls- List directory contentspwd- Print working directorytab completion- Auto-complete filenames
-
Initial exploration:
ls -la pwd -
Attempting to read the file (this won't work):
cat spaces in this filename # This treats each word as a separate filename
-
Getting the password using backslash escapes:
cat spaces\ in\ this\ filename
-
Alternative method using quotes:
cat "spaces in this filename"
- Whitespace handling: Spaces in filenames need special treatment in shell commands
- Escape characters: Using backslash (
\) to escape special characters - Quoting: Using quotes to group words as a single argument
- Tab completion: A practical way to handle complex filenames
The shell normally treats spaces as argument separators. When you type cat spaces in this filename, the shell interprets this as trying to cat four separate files: "spaces", "in", "this", and "filename". By escaping each space with \ or wrapping the entire filename in quotes, we tell the shell to treat it as a single filename.
- Spaces are word delimiters in shell commands
cat spaces in this filename=cat "spaces" "in" "this" "filename"(4 separate files)cat spaces\ in\ this\ filename= treat as one filename with spacescat "spaces in this filename"= treat everything in quotes as one filename
# Using single quotes
cat 'spaces in this filename'
# Using tab completion (most practical)
cat spa<TAB>
# This will auto-complete to: cat spaces\ in\ this\ filename
# Using wildcards (if unique enough)
cat spa*
cat *filename- Tab completion is often the easiest method - just type the first few characters and press Tab
- Double quotes preserve the filename while allowing variable expansion
- Single quotes preserve everything literally (no variable expansion)
- Backslash escaping is precise but tedious for long filenames with many spaces
When dealing with files that have spaces, tab completion is your friend! Just type the first few characters of the filename and press Tab - the shell will automatically add the necessary escape characters.
Next: Level 3 π‘ 4