Level Goal
The password for the next level is stored in a file called spaces in this filename located in the home directory
Commands you may need to solve this level
ls, cd, cat, file, du, find
Helpful Reading Material
Solution
ssh bandit2@bandit.labs.overthewire.org -p 2220
This is a OverTheWire game server. More information on http://www.overthewire.org/wargamesbandit2@bandit.labs.overthewire.org's password:
Note: The following solution works because there is only 1 file that starts with the word “spaces”
bandit2@bandit:~$ ls
spaces in this filename
bandit2@bandit:~$ cat spaces*
UmHadQclWmgdLOKQ3YNgjWxGoRMb5luK
Asterisks (*) in Linux
The “*” is one type of wildcard that we can used to match characters. In our case we are using it to match any files that start with the word “spaces”. This helps us not have to type out the remainder of the file name which has spaces. If we type in the name with spaces the command line interprets each word as a file name instead of the name of a single file.
Alternate solutions
bandit2@bandit:~$ cat spaces\ in\ this\ filename
UmHadQclWmgdLOKQ3YNgjWxGoRMb5luK
bandit2@bandit:~$ cat 'spaces in this filename'
UmHadQclWmgdLOKQ3YNgjWxGoRMb5luK
- “\” is an escape character and helps us preserve the literal value of a character. In our case the character we are trying to preserve is the space character. We don’t want the command line to interpret the space as meaning we are starting the name of a new file. Rather, we want to preserve its literal value as a “space” that helps make up the name of a file.
- Enclosing the name of our file in single quotes also helps us preserve the literal value of each character.
References