Skip to content

Make folders and files: mkdir and touch

Create directories with mkdir and mkdir -p and empty files with touch, then check your work with ls, in a free practice terminal in your browser.

Lesson 4 of 165 minSkip to the terminal ↓

mkdir (make directory) creates a new directory:

mkdir recipes
ls

It only makes the last name in the path. mkdir a/b/c fails if a/b doesn't exist yet; add -p (parents) and mkdir makes every missing level on the way, and doesn't complain about ones that already exist:

mkdir -p notes/2026/january

touch creates an empty file, ready to be filled later. If the file exists, it leaves the contents alone and just updates its time:

touch notes/2026/january/ideas.txt
ls notes/2026/january

Both take several names at once: mkdir drafts final makes two directories, touch a.txt b.txt two files.

Naming things

Linux allows almost any name, but some make life harder. A name with a space has to be quoted every time (touch "my file.txt"), so most people use dashes or underscores instead: my-file.txt. Names are case-sensitive, so Notes and notes are two different directories.

Your task

Make the directory ~/projects/recipes/desserts (the recipes level doesn’t exist yet), then create an empty file called brownies.txt inside it.

  • Make ~/projects/recipes/desserts (not done yet)
  • Create desserts/brownies.txt (a file) (not done yet)

Lesson 4 of 16.

learner@sandbox: ~bash (practice)
Note: Practice shell for this lesson. Type a command and press Enter (help lists them all).