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.
Quick check
mkdir refuses to create a folder that already exists. Why is that good?
mkdir -p — the whole 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.
Tip
-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.
Quick check
Neither a nor a/b exists. Which command creates a/b/c?
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.
Note
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.txtneeds quotes every single time.my-notes.txtnever does. - Lowercase. Some systems treat
Notes.txtandnotes.txtas the same file and some do not. Staying lowercase means never finding out the hard way. - Dashes between words.
hello-worldreads well and types easily.
Quick check
Why avoid spaces in file names you create in the terminal?
Try it
Build a small project skeleton:
mkdir -p projects/hello-world— the folder and its parent in one step.cd projects/hello-world— go in.touch notes.txt— create an empty file.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.