LARP it
Mission. Set up a secret base on this machine: a folder, a file with your codename in it, and a log of the mission. Then prove it worked by reading it back.
cd ~
mkdir secret-base
cd secret-base
touch notes.txt
echo "codename: ghost" > notes.txt
echo "mission 1: complete" >> notes.txt
cat notes.txt
ls -l
Learn it
| Command | What it does |
|---|---|
mkdir secret-base |
make a directory (folder) |
touch notes.txt |
creates an empty file, or updates the time on an existing one |
echo "text" |
prints the text back to you |
cat notes.txt |
prints the whole file (short for concatenate) |
The new idea here is redirection. Normally a command prints to the screen. The > and >>
arrows send that output into a file instead:
>replaces the file’s contents. Run it twice and only the last line is left.>>appends to the end of the file and keeps what was there.
So echo "codename: ghost" > notes.txt writes one line into the file, and the >> line adds a
second one below it.
Careful:
>overwrites without asking. If you point it at a file that matters, its old contents are gone. When in doubt, use>>.
That’s the core loop of the terminal: small commands, each doing one thing, joined together by arrows. Most developer tools (git, npm, python) are just more commands that work the same way.
Check it
- Add a third line to
notes.txtwithout losing the first two. Read the file to prove it. - Run
echo "oops" > notes.txt, thencat notes.txt. What happened, and why? - Make a folder
secret-base/inteland a file inside it, using only paths from your home folder (nocd).
Course complete. You can open a terminal, move around a computer and create files without a
mouse. Next, try it on a real task: next time you’d open a folder in Finder or Explorer, use cd
and ls instead.