Bandit 2 → 3: spaces in the filename
Straight after the dash file, another name that fights the shell — this time with spaces in it. Different reason, same shape of problem: the thing you type and the thing the tool receives are not the same thing.
the goal
The password for the next level is stored in a file called
spaces in this filenamelocated in the home directory.
the approach
bandit2@bandit:~$ ls
spaces in this filename
One file, four words. Coming straight off the last level I reached for ./
again on reflex — that part isn’t actually needed here, nothing about this name
confuses cat. The spaces are the problem, and they’re a shell problem, not a
cat problem: the shell splits your command on whitespace before cat ever
sees it, so the bare version hands it four separate filenames to open.
Escaping each space with a backslash keeps it as one argument:
bandit2@bandit:~$ cat ./spaces\ in\ this\ filename
Quotes do the same job with less typing:
bandit2@bandit:~$ cat "spaces in this filename"
And tab-completion writes the backslashes for you — type cat sp, hit Tab, and
the shell fills in the rest already escaped.
the takeaway
Whitespace is an argument separator before it’s a character in a name. Three ways to say “this is all one thing”: backslash each space, wrap the whole thing in quotes, or let Tab escape it for you.
Quotes are the one to reach for deliberately. Tab is the one you’ll actually use — and it’s worth using precisely because it escapes correctly every time, including for names you haven’t looked at closely yet.