Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions command-line/introduction/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ To access the command line, we use a terminal emulator, usually called a termina

## Example 1: navigating around in the terminal

Once you opened up your terminal, type in the following after the $ or > sign and hit enter: ($ or > is the prompt, you don't have to retype that in the terminal, only the characters that come after them):
Once you opened up your terminal, type in the following after the `$` or `>` sign and hit enter: (`$` or `>` is the prompt, you don't have to retype that in the terminal, only the characters that come after them):

```bash
$ pwd
Expand All @@ -23,7 +23,7 @@ $ pwd

### `pwd` or print working directory

The `pwd` command prints out the current directory you are in. What are directories? Directories are folders, these terms are used interchangeably. If you just opened up your terminal, you are probably in the root directory of your computer, and should get an output similar to this:
The `pwd` command prints out the current directory you are in. What are directories? Directories are folders, these terms are used interchangeably. If you just opened up your terminal, you are probably in the home directory of your computer, and should get an output similar to this:

```bash
/Users/your-username
Expand All @@ -39,7 +39,7 @@ In your terminal type:
$ ls
```

and hit enter. Most likely this command returned you a bunch of files and directories (folders). The `ls` command prints out the contents of a directory. If you are in the root directory of your computer you should see directories printed out such as Documents, Applications, etc. Now the question is, how do I move between directories?
and hit enter. Most likely this command returned you a bunch of files and directories (folders). The `ls` command prints out the contents of a directory. If you are in the home directory of your computer you should see directories printed out such as Documents, Applications, etc. Now the question is, how do I move between directories?

### `cd` or change directory

Expand All @@ -63,7 +63,7 @@ Now type:
$ pwd
```

This should return you name of the directory you just `cd` into.
This should return you the name of the directory you just `cd` into.

Type `ls` into the terminal, choose another directory and `cd` into it. We have just changed into a new directory. You can use these two commands to navigate around the directory structure of your computer. This is all good so far but sometimes you might want to go deeper than one level in one command. `cd` allows you to do this by chaining the directories with a `/`, so `cd your-directory` becomes `cd your-directory/directory-inside-your-directory`.

Expand All @@ -73,25 +73,25 @@ We now know how to move forward but how to go back up the directory tree? In you
$ cd ..
```

Now do a `pwd`. You just went back one directory! Chaining works backward too, so if you type `cd ../..` you should be taken back two directories.
Now do a `pwd`. You just went back one directory! Chaining works backwards too, so if you type `cd ../..` you should be taken back two directories.

> If you want to go back to the root directory of your computer, simply type `cd` into the terminal. `cd` without an argument takes you back to the root directory regardless of where you are currently in the directory structure
> If you want to go back to the home directory of your computer, simply type `cd` into the terminal. `cd` without an argument takes you back to the home directory regardless of where you are currently in the directory structure

### Exercise 1: use `ls` and `cd` to move in and out of a few directories on your machine
### Exercise 1: use `ls` and `cd` to move in and out of a few directories on your computer

Those are the basics of navigating around in the terminal. What else would we want to do in there? How about creating directories and files?
These are the basics of navigating around in the terminal. What else would we want to do in there? How about creating directories and files?

## Example 2: creating directories and files

### `mkdir` or make directory

Go back to the root directory of your computer, and type:
Go back to the home directory of your computer, and type:

```bash
$ mkdir temp
```

into the terminal. Now use `ls` to see the contents of the root directory. You should see a new folder, temp there. You just created a new folder! As it's name suggests, mkdir creates directories. What if we wanted to create a directory inside a directory? `cd` into temp and type:
into the terminal. Now use `ls` to see the contents of the home directory. You should see a new folder, temp there. You just created a new folder! As it's name suggests, mkdir creates directories. What if we wanted to create a directory inside a directory? `cd` into temp and type:

```bash
$ mkdir stuff/bits
Expand All @@ -111,7 +111,7 @@ Do an `ls` to check whether the file has been created. Inside bits, there should

### Exercise 2: `cd` back into temp and create a couple of new folders with files in them

### Bonus: type this into your terminal:
### Bonus: if you are on a Mac, type this into your terminal:

```bash
$ say hello
Expand Down