Only Murders in the Terminal
Quick Disclaimers -
This is a solution and walk-through of the problem - https://sadservers.com/newserver/command-line-murders#
To get the most out of this exercise, please attempt it seriously once yourself.
I try to explain all commands to keep it very beginner friendly.
Let's get into it now -
Not much to go unwrap in the description of the task, so lets check the server right away.
Not much to look into home directory, lets check clmystery folder.
cd clmystery
cat instructions
Command Explanations -
cd - change directory
cat - prints output of any file
quick look at instructions gives us our first clue
You'll want to start by collecting all the clues at the crime scene (the 'crimescene' file).
The officers on the scene are pretty meticulous, so they've written down EVERYTHING in their officer reports.
Fortunately the sergeant went through and marked the real clues with the word "CLUE" in all caps.
ok, so we gotta look at the crimescene file
cd mystery
cat crimescene | grep CLUE
first command that requires some unpacking.
"|"
pipe allows us to combine multiple commands. It passes the output of first command to the next one.
Grep
grep is an incredible tool for searching to search for matching patterns in linux. more info here - https://www.freecodecamp.org/news/grep-command-in-linux-usage-options-and-syntax-examples/
another example of what we did
ls | grep *.txt
- this would only list files with .txt pattern
Great, now onto the actual info
The gist of the info is -
Suspect is is a tall male, at least 6'
Suspect is part of the few clubs listed there
Woman named Annabel is a potential witness
crimescene
interviews/
memberships/
people/
streets
vehicles
bunch of files and folders to explore, My first thought was just find all info with Annabel in it.
grep -r "Annabel" interviews
grep "Annabel" people
Command Explanations -
This command will search for the string "Annabel" in all files within the "interviews" directory and its subdirectories. The -r
flag stands for recursive, and it allows grep
to search through subdirectories.
welp, nothing in interviews.
BUT, JACKPOT in people file
Annabel Sun F 26 Hart Place, line 40
Oluwasegun Annabel M 37 Mattapan Street, line 173
Annabel Church F 38 Buckingham Place, line 179
Annabel Fuglsang M 40 Haley Street, line 176
we can right away remove 2 people from the list of witness as they are male, and keep our focus on the female Sun and Church.
Let's try searching with these keywords in interviews again
grep -r "Sun" interviews
grep -r "Church" interviews
output for sun
interviews/interview-47246024:Ms. Sun has brown hair and is not from New Zealand. Not the witness from the cafe.
well, so sun isnt our witness. So it has to be Church
output from Church
interviews/interview-699607:Interviewed Ms. Church at 2:04 pm. Witness stated that she did not see anyone she could identify as the shooter, that she ran away as soon as the shots were fired.
lets look at her full statement
cat interviews/interview-699607
Interviewed Ms. Church at 2:04 pm. Witness stated that she did not see anyone she could identify as the shooter, that she ran away as soon as the shots were fired.
However, she reports seeing the car that fled the scene. Describes it as a blue Honda, with a license plate that starts with "L337" and ends with "9"
we found our next clue lets go.
grep 'Honda' vehicles
grep 'Honda' vehicles | wc -l
grep -C 5 'L337' vehicles
grep -C 5 'L337' vehicles | grep -C 5 Blue
Command Explanations -
grep 'Honda' vehicles | wc -l
wc -l gives us the count of lines.
way too many vehicles from Honda. It would be too hard to list down our suspect from this.
So, I tried with L337. (Success, only 13 listings)
To further shortlist, I grep the output against blue
grep -C 5 'L337' vehicles
this command provides context. It prints n number of lines before and after the matching string. In this case 5 lines above and below
grep -C 5 'L337' vehicles | grep -C 5 Blue
We can manually go through the few outputs to find tall males above 6ft
Owner: Jacqui Maher
Owner: Jeremy Bowers
Owner: Joe Germuska
We have our 3 suspects, now it only remains to check these names against the data in memberships to match with the info we got in our first clue.
I wont add the exact commands to do that, with all the commands shared previously. It should be relatively easy.
To confirm your findings here's the final culprit -
Joe Germuska