Creating directories and files
Every project starts the same way: create a directory skeleton, drop in some starter files, begin working. Doing that with commands instead of clicks means it can be scripted (unit 8) and repeated identically on any machine — including servers, where clicks are not an option.
You've been borrowing these commands since lesson 1-2. Now let's own them:
mkdir name: make directory. Fails if the parent doesn't exist.mkdir -p a/b/c: the-pflag creates the whole chain of parents in one go, and doesn't complain if some already exist.touch name: creates an empty file. If the file already exists, it just updates its "last modified" time (that's actually its official job).
Both accept several names at once: touch a.txt b.txt c.txt.
Code exercise · bash
Run it. One mkdir -p builds two directories under site/, touch drops files into them, and ls (with a path argument!) lists each directory without cd-ing into it.
Two ls flags worth knowing now
ls -a: show all entries, including hidden ones. Any name starting with a dot (like.bashrc) is hidden from plainls. That's the entire hiding mechanism, just a naming convention. You'll meet these "dotfiles" properly in unit 7.ls -l: long format. One line per entry with permissions, owner, size, and date. The permission string at the start (like-rw-r--r--) is decoded in unit 6.
Flags combine: ls -la shows everything, in detail.
Code exercise · bash
Run it: we create a normal file and a hidden one. Plain ls shows only the visible file. ls -a (filtered to the interesting line with grep, unit 4's star) reveals the hidden one.
Quiz
What does the -p in `mkdir -p app/src/utils` do?
Code exercise · bash
Your turn. Build this project skeleton, then list it: - directories `app/src` and `app/docs` (one mkdir -p) - files `app/readme.md` and `app/src/main.py` - then `ls app` and `ls app/src` Expected output: ``` docs readme.md src main.py ```