← Teacher guide

Where files live

Students move around a pretend Linux filesystem with pwd, ls and cd, reading full paths, short paths, .. and ~, with a folder tree beside the terminal (AC9TDI10K01 node 1, the operating system's file system).

The command line · Using a shell · about 40 minutes · Open the student lesson

Classroom resources

Load these into Waypoints Prepare: choose Load URL and paste the copied address, or download the file and import it. In Prepare, the worksheet's Teacher edition shows the answers; the student copy hides them.

Students will be able to

Timing

Predict and Try 8 min · Worked example 10 min · Vary 10 min · Practise and Make 12 min

Before class

Try the boards yourself. Everything runs in the browser on a pretend computer; nothing touches the school's machines.

The one idea: files live in a tree, and a path names a place in it. The folder tree is on for the Try and Vary and off for the Make, so students build the path themselves.

For the real thing (optional, after the course): a Raspberry Pi is best; WebVM runs Linux in a browser tab with no install (test it on the school network first); Mac Terminal works with the same commands; WSL or VirtualBox on Windows need admin rights.

Running the lesson

  1. Predict: students who said /projects think cd starts from the top.
  2. Try: ask what the prompt shows after each cd.
  3. Worked example: model reading a path aloud: "from the top, home, sam, projects".
  4. Vary: ask which way works from anywhere.
  5. Make: no tree: ask how they knew where to go.

The hard part (on purpose)

The first minutes at a prompt feel like guessing. Let students type and get it wrong: the board is pretend, errors are friendly, and the tree shows where they are.

When students get stuck

What you will seeA question to askThe fix
A student thinks cd moved their files (Sam's mistake).Go back with cd .. and ls. Is notes.txt still there?cd moves you; files stay put.
A student gets "No such folder".Is that folder inside the one you're in? Check with ls.Use the right short path, or a full path from /.

Answers to the checks

  1. where will you be?: You are in /home/sam. You type cd projects, then pwd. What does pwd show?
    /home/sam/projects: cd moved you into the projects folder inside where you were, and pwd prints the full path.
  2. Try: find your way: Get to the game folder. Type ls to look around and cd to move; the tree shows where you are.

    cd projects, then cd game (or cd projects/game in one go). The prompt and the tree both show where you are.
  3. Three ways to name one folder: You are in /home/sam/projects/game. You type cd ../.. Where are you now?
    /home/sam
    Each .. goes up one folder: game → projects → sam.
  4. Find the mistake: Sam explains what cd does. Click the line where it first goes wrong.
    line 3
    Line 3: cd moves you, not your files. notes.txt stays in /home/sam; mv is the command that moves files.
  5. Which command?: Which command lists what is in the folder you are in?
    ls
    ls lists files and folders (folders end with /).
  6. A full path: Go to the folder /etc with one cd, using a full path.

    cd /etc: a full path starts with / and works from anywhere.
  7. Up with ..: You start in projects/game. Get to the photos folder using ..

    cd ../../photos: up to projects, up to sam, then down into photos.
  8. Home: You start in /etc. Get home with the shortest command you can.

    cd on its own (or cd ~) always goes home.
  9. Full paths: Which path works from any folder?
    /home/sam/photos
    Paths that start with / start from the top.
  10. The prompt: The prompt says sam@school:~/projects$. Where are you?
    /home/sam/projects
    ~ means /home/sam, so ~/projects is /home/sam/projects.
  11. Review: the OS: Review: the same ls command works on an SSD, a USB stick or a network drive. Why?
    The operating system hides the difference; ls just asks it for the folder
    Commands ask the operating system, which uses the right driver for each kind of storage.
  12. find and read a file: There's a file called level1.txt somewhere in your home folder. Find it and print it with cat.

    You found it by looking (ls) and moving (cd), then read it (cat): the three moves of every shell.

Solutions

One possible solution for each task. Other correct programs are fine.

Vary: other ways to move › A full path

Open task: any program that does what the step asks.

Vary: other ways to move › Up with ..

Open task: any program that does what the step asks.

Vary: other ways to move › Home

Open task: any program that does what the step asks.

find and read a file

Open task: any program that does what the step asks.

Stretch and support

Stretch: Press Tab after typing the start of a folder name. What does it do? (It completes the name.)

Support: A card with four commands: pwd (where am I?), ls (what's here?), cd name (go in), cd .. (go up).

Exit ticket

You are in /home/sam/photos. Write the command to get to /home/sam/projects in one step.

cd ../projects (or cd /home/sam/projects, or cd ~/projects).

What each step is for

Where it leads

Next: Reading and finding (cat, grep, hidden files).

Links: Security and privacy › What the operating system does.