Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Step 6 Suspects #2726

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions clmystery
Submodule clmystery added at fc2b9e
2 changes: 2 additions & 0 deletions clmystery-main/.travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
script:
- find ./ -name "jail.txt" | xargs less | $(command -v md5 || command -v md5sum) | grep -qif /dev/stdin encoded
10 changes: 10 additions & 0 deletions clmystery-main/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
License
=======

Available under the MIT license.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions.

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
66 changes: 66 additions & 0 deletions clmystery-main/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
The Command Line Murder
========================

.OOOOOOOOOOOOOOO @@ @@ OOOOOOOOOOOOOOOO.
OOOOOOOOOOOOOOOO @@ @@ OOOOOOOOOOOOOOOO
OOOOOOOOOO'''''' @@ @@ ```````OOOOOOOOO
OOOOO'' aaa@@@@@@@@@@@@@@@@@@@@""" """""""""@@aaaa `OOOO
OOOOO,""""@@@@@@@@@@@@@@"""" a@"" OOOA
OOOOOOOOOoooooo, |OOoooooOOOOOS
OOOOOOOOOOOOOOOOo, |OOOOOOOOOOOOC
OOOOOOOOOOOOOOOOOO ,|OOOOOOOOOOOOI
OOOOOOOOOOOOOOOOOO @ THE |OOOOOOOOOOOOOI
OOOOOOOOOOOOOOOOO'@ COMMAND OOOOOOOOOOOOOOb
OOOOOOOOOOOOOOO'a' LINE |OOOOOOOOOOOOOy
OOOOOOOOOOOOOO'' MURDERS aa`OOOOOOOOOOOP
OOOOOOOOOOOOOOb,.. `@aa``OOOOOOOh
OOOOOOOOOOOOOOOOOOo `@@@aa OOOOo
OOOOOOOOOOOOOOOOOOO| @@@ OOOOe
OOOOOOOOOOOOOOOOOOO@ aaaaaaa @@',OOOOn
OOOOOOOOOOOOOOOOOOO@ aaa@@@@@@@@"" @@ OOOOOi
OOOOOOOOOO~~ aaaaaa"a aaa@@@@@@@@@@"" @@ OOOOOx
OOOOOO aaaa@"""""""" "" @@@@@@@@@@@@"" @@@|`OOOO'
OOOOOOOo`@@a aa@@ @@@@@@@"" a@ @@@@ OOOO9
OOOOOOO' `@@a @@a@@ @@"" a@@ a |@@@ OOOO3
`OOOO' `@ aa@@ aaa""" @a a@ a@@@',OOOO'


There's been a murder in Terminal City, and TCPD needs your help.

Before you start, skim through the required materials in the Command Line and Version Control sections of the PreCourse on Teachable. Use it as a reference while working through the case.

Now with your Terminal at hand you're ready to start. A couple of ground rules first:

- **Don't use a text editor**. You will find that the command line is an incredibly powerful tool on its own.
- You can use Google, PreCourse materials, cheatsheets or any other materials available.

# To the investigation!

## Step 1: Get the repo

First you need to fork this [repository](https://help.github.com/articles/github-glossary/#repository). To do that click on the "Fork" button in the upper right corner of this page. Forking a 'repo' creates a copy of the repository on your Github account. This gives you your own version of the project to experiment with.

![Fork](./img/fork_button.jpg)

Next you need to download those files to your machine so that you can edit them. To do that you must clone your forked repository. See [this Github guide](https://help.github.com/articles/cloning-a-repository/) on how to do this.

## Step 2: Investigate

Each step of your investigation will contain a reference to the **Detective Handbook** at the top. Each page of the Detective Handbook contains the description of the commands you will need to complete that particular step.

Open a Terminal, go to the location of the files (using the `cd` command), and start by reading the file 'step0'.

One way you can do this is with following command:

cat step0

(`cat` is a command that will print the contents of the file called `step0` for you to read.)

### Credits

By Noah Veltman
Projects: [noahveltman.com](http://noahveltman.com)
GitHub: [veltman](https://github.com/veltman)
Twitter: [@veltman](https://twitter.com/veltman)

Adapted by the Makers Academy Team
37 changes: 37 additions & 0 deletions clmystery-main/detective_handbook/getting_started.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Command Line - Introduction

## Mac vs PC

Before we dive into using the command line, it's important to discuss the distinction between using a UNIX-based computer (Mac, any Linux including Ubuntu, etc.) or a PC running Windows. In these lessons, we're assuming you're using a Mac as it's the most common platform among web developers. With the technologies we cover at Makers – a Mac is the tool of choice. If absolutely required, you can use Ubuntu, but you may encounter minor problems along the way that we won't usually cover at Makers. This does not imply that Mac is somehow superior to Linux when it comes to web development. It is simply different, so the instructions provided for a Mac may not always work on a different system.

If you don't have access to either a Mac or Linux machine you may find it easier to work with a cloud hosted solution such as [C9](https://aws.amazon.com/cloud9/?origin=c9io). This might run a little slower, but the C9 terminal is a good substitute and can be used from PCs and even Chromebooks.

## What is the command line?

So what is the command line exactly? The command line is how we interact directly with the underlying code of our computer. Every computer has some way of accessing the command line. In fact, the command line is the primary interface that your computer uses. The graphical user interface (all the beautiful windows you can open) is just a more accessible way of using your computer that is often but not always available. For example, servers (computers in a data center that host websites etc.) often don't have graphical interface at all, so command line is the only way to work with them.

Using the command line on a Mac is done through the "Terminal" application. You can find it using Spotlight (the built-in search functionality in OSX). Press this combination:

`⌘ + Space Bar`

This will open Spotlight in the upper-right corner of the screen. Search for "Terminal" and scroll down until you find it, select it and hit enter.

The terminal application will open and you'll see something like this:

![Bash command line Image](https://dchtm6r471mui.cloudfront.net/hackpad.com_ymW6Sl1t69J_p.52567_1380900937026_Screen%20Shot%202013-10-04%20at%2016.35.09.png "Bash image")

As you can see, it will show you the name of your computer ("Makers Academy laptop") and what directory you're currently in ("Desktop"), followed by the name of the currently logged in user. At the end of the prompt, you'll see a dollar sign ($). This just represents the end of the prompt so if you ever see it used as an example, it doesn't need to be typed in.

Note: you can get something similar at the bottom of the Nitrous Web IDE:


![Nitrous command line](https://www.dropbox.com/s/qdvp81om2571pn7/Screenshot%202014-10-15%2010.45.09.png?dl=1 "Nitrous command line")


Directories in the command line are just a different way to access the directories (or folders) you already have on your computer. So, for example, you can see in the screenshot that I'm currently in the "Desktop" directory. If I were to delete a file that's in that directory from the command line, it will delete it from the user-interface that you're used to using as well.

Don't forget that if you can access the history of your commands by pressing up and down arrows, so if you want to run the command you type a minute ago, just press the up arrow until you see it.

Now that you have the Terminal open, if you are on a Mac, I recommend right clicking on the icon and selecting Options → Keep in Dock. We'll be using the terminal a lot so you want easy access to it.

![alt text](https://dchtm6r471mui.cloudfront.net/hackpad.com_ymW6Sl1t69J_p.52567_1380901047979_Screen%20Shot%202013-10-04%20at%2016.37.09.png "Keep in dock")
3 changes: 3 additions & 0 deletions clmystery-main/detective_handbook/git.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
**Git**

Take a look back through the various [git lessons on Teachable](https://makersacademy.teachable.com/courses/256825/lectures/3989156) to refresh your memory of git and the various commands.
21 changes: 21 additions & 0 deletions clmystery-main/detective_handbook/step0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# `ls`

The name of the `ls` command stands for "list". If you just type `ls` without arguments the command will list files in the current directory. You can also list files in another directory by calling `ls` with the directory name: `ls mystery/`

# `cd`

`cd` is short for "change directory". Type `cd mystery/` to change current directory to "mystery". To go one level up type `cd ..`. By convention `..` stands for the "parent directory".

# `cat`

`cat FILENAME` is the command you're going to use to view files from the command line. The `cat` command literally means "concatenate" (just a fancy word for "combine") as combining files is its primary purpose, but it is widely used for listing a content of just one file.

# `man`

There will be any number of situations where you'll have a question about what command to use or wonder what a command is truly designed for. Let's see how to handle those situations.

`man ls`

The "man" or "manual" command takes a parameter of another command to provide you more information about it.

Try to use `man` to find out more about `cat`, `ls` and `cd`.
31 changes: 31 additions & 0 deletions clmystery-main/detective_handbook/step1-git.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
This reference contains only the commands you will need to complete Step 1.

Take some time to read through the [Git walkthrough](./git.md) and make yourself familiar with the important Git concepts.

Use `man git` to see what Git creators have to say about it.

# `git --help COMMAND`

Git has very extensive documentation. To learn more about any Git command type `git --help COMMAND_NAME`.

# `git status`

Git status shows what changes you have made since the last commit. The output of the `git status` command is divided into three sections: changes staged for commit, changes not staged for commit and untracked files.

- Changes staged for commit are the changes that will be added to your next commit unless you specify what else do you want to add.

- Changes not staged for commit will not be committed if you don't add them explicitly.

- Untracked files are the files that you created but haven't yet added to git. Git doesn't track new files automatically because you might not want to add some files to the version control.

# `git add`

`git add` is used for adding changes to the "staging area" - i.e. to mark the changes as something you want to add to the next commit. `git add .` will add all the changes in the working directory to the staging area

# `git commit`

`git commit` is the command to commit all the changes in the staging area to git. Type `git commit -m "COMMIT MESSAGE"` to create a commit with a comment describing what the commit is about.

# `git push`

After you have committed the changes, they still only exist on your machine. To "share" the work you need to push the changes to a remote repository. If you cloned the repository from Github you already have a remote repository setup. When you push your changes they will be pushed to Github. Type `git push` to push your commits.
45 changes: 45 additions & 0 deletions clmystery-main/detective_handbook/step1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Absolute and relative paths

There're two ways of addressing a path from the command line - typing in an absolute path or a relative path.

**Absolute paths** begin with `/`. `/` is a path too. It points to the **root** directory in the filesystem. All other paths start from the root. If your "clmystery" directory sits within your home folder the absolute path to the "clmystery" directory might look like this:

`/Users/johndoe/clmystery`

So change current directory to "mystery" you can type in `cd /Users/johndoe/clmystery/mystery`.

**Relative paths** are paths specified from some other location rather than root folder. For example "mystery" directory can be accessed from the "clmystery" directory by its relative path: `cd ./mystery/` or `cd mystery/`.

`.` in the path refers to the current directory. `..` to the parent directory. If you don't prefix the path with anything (like `cs mystery`) command line will consider this to be a relative path from the current directory.

# `less`

`less` command lets you view a file one screen at a time.

Using the "less" command, you're able to scroll up and down with your keyboard to view the entire document. When you're ready to finish viewing, just type "q"

Use `man less` to learn more about the `less` command.

# `touch`

`touch FILENAME`

The "touch" command creates an empty file with a given name.

# `grep`

The `grep` command allows you to search for a certain word or a phrase within a file. The `grep` command takes two parameters: the first is what you want to search for and the second is what files you want to search through.

`grep Siamese cats.txt`

`grep 'Maine Coon' cats.txt`

Use `man grep` to learn more about how to use `grep`.

# `>`

`>` operator allows you to save the output of a command to a file instead of printing it to a screen. For example with `grep` you can save the results of your search like this:

`grep bengal cats.txt > bengal_cats.txt`

This will override the contents of the "bengal_cats.txt" file with the results of `grep`. To append command output to a file instead use `>>`.
27 changes: 27 additions & 0 deletions clmystery-main/detective_handbook/step3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Wildcard

`ls kitties/` prints out all files in the 'kitties' directory. What if you only want to print out txt files? Or files with names starting with "cute_"? To do that you can use asterisk symbol:

`ls kitties/*.txt`

`ls kitties/cute_*`

The asterisk (wildcard) is a "match all" symbol. When you type `ls kitties/cute_*` command line interprets it as "print all the files in the kitties directory that start with 'cute_'". The rest of the name could be anything as `*` matches all possible strings.

# `find`

`find` is a command to find files matching certain criteria. The most common example is finding files by name:

`find . -name "*.txt" -print`

This command works a lot just like normal English. It's saying: "find all files, starting with the current directory, with any name that ends in .txt and print it to the screen." Another cool feature of the "find" command is that, if you have additional directories inside the directory you search in, it will go into those directories as well and continue the search.

# `ls` with flags

`ls -a` prints all files and directories including the ones whose names begin with `.`

`ls -l` prints all files as a list with all the information about files like permissions, owner, last modified time and size.

`ls -h` when used with `-l` option prints file size in a human readable format (Kbytes, Mbytes etc.) instead of bytes.

Flags can be combined. You can type `ls -lah` instead of `ls -l -a -h`.
13 changes: 13 additions & 0 deletions clmystery-main/detective_handbook/step4.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# `head`

`head -N` command will print out first N lines of the file.

# `tail`

`tail -N` is the opposite of `head`. It will print out last N lines of the file.

# `|`

The pipe operator - `|` - allows you to "pipe" or direct the output of one command into the input of another command. For example if you wish to search for "British" in 'kitties.txt' and then search for "Shorthair" in the results of the first search you can use the combination of `grep` and `|`:

`grep British kitties.txt | grep Shorthair`
15 changes: 15 additions & 0 deletions clmystery-main/detective_handbook/step5.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# `git branch`

Branches in Git allow you to work on several different versions of your working directory at the same time. When you create a new branch and start tracking your changes they'll be saved only in this new branch. At any moment you can switch back to your original (e.g. "main") branch and all your files will be in the same state you left them before "branching out" regardless of the work you've done in the new branch.

The `git branch` command allows you to see which branches you have locally. To see all branches including remote ones type `git branch -a`.

# `git checkout`

Use `git checkout BRANCH_NAME` to switch "active" or "current" branch. You can checkout to a new branch even if it's stored in the remote repository. When you do this, the branch will be copied to your machine and will be set as "current" branch.

# `git merge`

`git merge` allows you to merge two branches together. E.g. if your current branch is "main" and you type `git merge more-cats` all the changes in the `more-cats` branch will be applied to the "main" branch and a new commit (merge commit) will be created.

`git merge` will open your default command line text editor for you to confirm the merge commit message. Your default editor is likley to be Vim (you can check it by typing `echo $EDITOR`) see the PreCourse [section on Vim](https://makersacademy.teachable.com/courses/256825/lectures/3989204).
15 changes: 15 additions & 0 deletions clmystery-main/detective_handbook/step6.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# `grep` with context

`grep -A N SEARCH_STRING` outputs not only the line that contains a match but also N lines after that one.

`grep -B N SEARCH_STRING` is like `-A` but prints out N lines before the line with the match.

`grep -C N SEARCH_STRING` outputs N lines before and after the match string.

Use `man grep` to learn more about `grep` flags.

# Making a pull request on GitHub

You forked a repo, cloned it to your computer, made some changes committed and pushed them back to GitHub. Now if you want to submit those changes back to the original repo you would need to make a pull request (PR). The maintainers of the original repo can review your changes and decide if they want to merge them.

Refer to the [GitHub guide](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request-from-a-fork) to learn how to make a pull request.
11 changes: 11 additions & 0 deletions clmystery-main/detective_handbook/step7.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# `rm`

`rm` is the command for removing files. Type `rm FILENAME` to delete a file permanently. Type `rm -r DIRECTORY_NAME` to remove a directory.

# `git diff`

`git diff` allows you to see changes between any two points in your project. It could be changes between commits, or changes you made since the last commit. Type `git diff` to see the changes since the last commit. Type `git diff COMMIT1..COMMIT2` to see the difference between two commits.

# `git log`

`git log` prints out the commit history in the project. Using `git log` you can find out commit hashes to refer to them later (for example to use them in `git diff`).
12 changes: 12 additions & 0 deletions clmystery-main/detective_handbook/step8.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Using `cat` to concatenate files

Type `cat FILE1 FILE2` to print out the content of two files.

# `wc`

`wc` stands for "word count". This command can count words, bytes, characters, lines etc in the input.

`wc FILENAME` will output the number of lines words and bytes in a file. `wc -l FILENAME` will print out the number of lines in the file.

`ls -l . | wc -l` shows the number of entries in the current directory. `ls -l` prints out files and subdirectories as a list, then `wc -l` counts the number of lines in that list resulting in a number equal to the number of files and directories within current directory.

Loading