# Making things: mkdir and touch

Course: Terminal Basics — https://zero2vibecode.com/learn/terminal-basics
Canonical URL: https://zero2vibecode.com/learn/terminal-basics/1-4-mkdir-and-touch

`mkdir` makes folders, `touch` makes empty files, and `mkdir -p` builds a whole nested path in one go.

You can move around. Now make something.

## mkdir — make a folder

```
mkdir projects
```

Silent, as usual, which means it worked. Run `ls` and `projects` is there.

Run it a second time and you get an error:

```
mkdir: cannot create directory 'projects': File exists
```

That refusal is deliberate. `mkdir` will not quietly wipe an existing folder to give you a fresh one — you would lose everything inside it. Commands that could destroy your work generally make you say so explicitly.

## mkdir -p — the whole path at once

Say you want `projects/hello-world/src`, and none of it exists yet. Plain `mkdir` fails, because it only creates the last step and the earlier ones are missing:

```
mkdir projects/hello-world/src
mkdir: cannot create directory 'projects/hello-world/src': No such file or directory
```

The `-p` flag says "create the parents too":

```
mkdir -p projects/hello-world/src
```

One line, three folders. This is the version you will use most.

`-p` has a second, quieter benefit: it does not complain if the folder is already there. That makes it safe to re-run, which is why setup scripts use `mkdir -p` almost exclusively.

## touch — make an empty file

```
touch notes.txt
```

That creates an empty file. Zero bytes, but real: `ls` sees it, and you can write into it later.

If the file already exists, `touch` leaves its contents completely alone. It is safe to run on anything.

`touch` is named after what it really does on a real system: it updates a file's "last modified" timestamp, and creating the file when it is missing is a side effect. In practice, "make me an empty file" is what everybody uses it for.

## Naming things you will have to type

You will be typing these names for as long as the project lives, so a few habits save real pain:

- **No spaces.** `my notes.txt` needs quotes every single time. `my-notes.txt` never does.
- **Lowercase.** Some systems treat `Notes.txt` and `notes.txt` as the same file and some do not. Staying lowercase means never finding out the hard way.
- **Dashes between words.** `hello-world` reads well and types easily.

## Try it

Build a small project skeleton:

1. `mkdir -p projects/hello-world` — the folder and its parent in one step.
2. `cd projects/hello-world` — go in.
3. `touch notes.txt` — create an empty file.
4. `ls` — see it.

Four lines, and you have a folder structure with a file in it. Doing that with a mouse would have taken longer.
