In a world with , chapter 1.2.

THE PATH · SESSION 2 OF 66 · UNIT 1 · ACT I

Your Status Screen

Filesystem Navigation, Pipes, and Permissions

55 min read5 diagrams2 side quests6 terminals3,945 words10 code blocks

At a glance

PACE
Session 2 of 66 · suggested week 1. Continue when you are ready.
UNIT
Unit 1 · I Woke Up in a Terminal and All I Had Was a Blinking Cursor
ACT
Act I · Foundation
BEFORE
1.1 Welcome to the New World
AFTER
1.3 Save Points and Respawns
ARTIFACT
The filesystem-quest folder with a grep-searched bestiary and an executable quest-start.sh, plus the explorers-journal: notes, a commands list, a discoveries file built with pipes, and two scripts you made runnable with chmod +x
READ
55 min · 5 diagrams · 10 code blocks

The hook#

Last session you learned to talk to the machine. You made files and folders, wrote a journal entry with echo, and opened a project in VS Code without touching the mouse. That was your first foothold in the new world.

Today you learn to see.

Every adventurer who survives the first night learns to open the status screen. Stats, inventory, the map with a small dot that says you are here. Without it you walk in circles in the dark. With it, the dungeon is just rooms and doors.

In the terminal the status screen is built from three commands you half-know already, pwd, ls and cd, plus the flags that make them tell the whole truth. After today you will never feel lost in a filesystem again. You will know where you are, what is around you, who owns it, how big it is, and how to get anywhere in one line.

Then we go further than navigation. You will chain commands together with pipes, so the output of one becomes the input of the next: history | grep mkdir to find every folder you ever made, ls -la | grep ".txt" to see only the text files. You will learn redirection properly, the > and >> from the first session plus what they are actually doing. And you will meet permissions, the system that decides who may read, change and run every file on the machine, and chmod, the command that changes it, because the first time you write a script and the shell says Permission denied you need to know that it is not a bug, it is a lock, and you have the key.

These are the skills that separate someone who can use a terminal from someone who understands it. By the end you will navigate anywhere, search inside files, build command pipelines, and make scripts executable. Your status screen is about to get a lot more detailed.

As on day one, the page carries terminals. Each has a script you can replay with Run in terminal, then a prompt that is yours. Every box starts from the same clean home, /home/adventurer, with a few hidden files already in it, which matters today. Nothing you type here touches your machine. Make the mistakes here; then do everything again for real.

The idea#

The filesystem is a tree. One tree. At the very top is /, called the root, and everything on the machine hangs from it: /bin holds programs, /etc holds system configuration, /tmp is scratch space, /usr and /var hold more programs and the logs. Somewhere under the root is your home directory: /home/yourname on Linux and WSL, /Users/yourname on a Mac. The shortcut ~ always means your home, wherever you are.

Left, the filesystem drawn as one tree from the root slash: bin, etc, home with adventurer inside it (Desktop leading down to navigation-practice, dungeon, floor-2 and boss-room; Documents; projects), tmp, usr and var, each with a short note; right, the same boss-room reached by an absolute path starting at slash and by a relative path starting with dot-dot from projects, and a legend for slash, tilde, dot, dot-dot and dash
Fig 1 · The filesystem is one tree. An absolute path starts at the root and works from anywhere; a relative path starts where you are standing. Both reach the same door.

Every folder has exactly one parent and any number of children. That single fact is the whole of navigation. If you can see the tree, every path is just a route through it, and there are two ways to write a route.

An absolute path starts at the root. /home/adventurer/Desktop/navigation-practice/dungeon/floor-2/boss-room is a complete address: it works from anywhere, the way GPS coordinates work from anywhere. You can recognise one instantly: it begins with / (or with ~, which the shell swaps for your home before it looks).

A relative path starts from wherever you are standing. From your home, Desktop/navigation-practice goes down two branches; from inside floor-1, ../floor-2/boss-room goes up one and down two. Relative paths are shorter and are what you type most of the day, and they are also the source of most "No such file or directory" errors, because they only mean something from the right starting point.

Three tiny names do most of the work. . is the directory you are in. .. is its parent, one step towards the root. ~ is home. And -, used only with cd, is wherever you were before your last move. The misconception to drop now: absolute and relative paths are not two systems that go to different places. They reach the same folders. One starts from the root, the other from you.

cd is how you move. cd ~ or just cd goes home. cd Desktop goes down. cd .. goes up one; cd ../.. up two. cd / goes to the root. cd - goes back. And cd followed by any path, absolute or relative, takes you there if it exists and tells you clearly if it does not.

ls is how you look, and the flags are its superpowers. Every command has options, also called flags, that change how it behaves; in the first session they were a footnote, today they are the lesson. ls on its own gives you names. ls -l gives the long format: permissions, owner, size, date. ls -a shows all files, including the hidden ones whose names start with a dot. ls -la does both and is the single most-typed command in this programme. ls -lh prints sizes a human can read (4.0K instead of 4096). ls -lt sorts newest first, ls -lS biggest first, and ls -R walks into every subfolder, which you discovered in the first session.

Top, one line of ls -la pulled apart into columns with a label and meaning under each: d for type, rwxr-xr-x for permissions, 5 links, adventurer owner, staff group, 160 size, Aug 9 10:30 modified, my-folder name; bottom left, a six-line listing with the dot-files dimmed and an executable script in green; bottom right, the flags -l -a -la -lh -lt -lS -R -1 with one-line meanings
Fig 2 · ls -la is the status screen. Read a line left to right: type, permissions, links, owner, group, size, date, name. Dot-files are hidden for tidiness, not secrecy.

A long-format line looks like noise the first time. Read it left to right, once, with the picture. The first character is the type: d for a directory, - for a plain file. The next nine are the permissions, which we take apart later today. Then a link count you can ignore for now, the owner, the group, the size in bytes, the last-modified date, and the name. That is all it ever is.

Hidden files are not secret and not dangerous. Any file whose name begins with a dot is skipped by plain ls to keep the listing tidy, because such files are almost always configuration: .bashrc and .zshrc set up your shell, .gitignore will matter next session, .profile runs when you log in. ls -a shows them. Count them in your own home today; there are more than you think.

When a command confuses you, ask it. man ls opens the manual page for ls (press q to leave). ls --help prints the short form on Linux and WSL; a Mac's ls does not understand --help, so there use man ls. And explainshell.com labels every piece of any line you paste.

Pipes. This is where the terminal stops feeling like a list of tricks and starts feeling like a language. Every command has a standard output, the text it would print, which normally goes to your screen. The pipe character | sends that text somewhere else: into the standard input of the next command. ls -la | grep ".txt" runs ls -la, but instead of showing you the listing, hands it to grep, which keeps only the lines containing .txt and shows you those. history | grep "mkdir" finds every mkdir you have ever typed. cat notes.txt | wc -l counts the lines in a file.

Top, the line ls -la | grep .txt > text-files.txt drawn as a flow: ls -la prints a listing, a green pipe arrow sends it into grep which keeps matching lines, a yellow greater-than arrow sends that into the file; below, three cards for pipe, redirect and append, each with three example commands and what they do
Fig 3 · Standard output goes to the screen unless you send it somewhere: | into the next command's input, > into a file (replacing it), >> onto the end of a file.

Nothing is moved or saved when you pipe. The text streams from one program to the next in memory and disappears unless you also send it to a file. Which brings back the arrows. > sends standard output into a file, replacing whatever was there. >> adds it to the end. They combine with pipes exactly as you would hope: ls -la | grep ".txt" > text-files.txt filters first, then saves.

grep deserves its own sentence because you will use it every day for the rest of your career. It searches text for a pattern and prints the matching lines. grep "fire" goblin.txt finds the lines in that file that mention fire. grep -i ignores case. grep -r "TODO" . searches every file under the current folder and tells you which file each hit came from. Its pattern is a regular expression, which for today means one thing: a dot matches any character, so ".txt" also matches my-txt-notes. "\.txt" means a literal dot. You will see that bite in Where it breaks.

A few more tools for the belt, each one small. head file prints the first ten lines; head -3 the first three. tail prints the last ten. wc counts lines, words and characters; wc -l just lines. cp a b copies; mv a b moves or renames, which are the same operation to the machine. rm file deletes. rm -r folder deletes a folder and everything in it.

The demonstration#

Three walkthroughs: moving, chaining, unlocking. Press Run on each, then redo the parts that surprised you at the prompt.

Walkthrough 1: the navigation drill. Build a small dungeon under your Desktop and walk it every way there is. Before each pwd, say out loud where you think you are. The picture is the map.

Left, the navigation-practice dungeon drawn as rooms: home above Desktop above navigation-practice above dungeon, which splits into floor-1 (room-a, room-b) and floor-2 (boss-room, the target); right, the eight moves of the drill as rows: where you start, the cd command, and where it lands, colour-coded down a branch, up with dot-dot, absolute or tilde jumps, and dash for back
Fig 4 · Every cd is a move on the map. Down a branch with a relative path, up with ., anywhere with an absolute path or ~, and back to the previous room with -.

SHyou type
cd ~pwdcd Desktoppwdmkdir navigation-practicecd navigation-practicemkdir -p dungeon/floor-1/room-a dungeon/floor-1/room-b dungeon/floor-2/boss-roomcd dungeonlscd floor-1lscd room-apwdcd ..pwdcd ..pwdcd floor-2/boss-roompwdcd ~pwdcd ~/Desktop/navigation-practice/dungeon/floor-2/boss-roompwdcd -cdpwd
Shell simulatoradventurer@newworld · simulated bashnot run yet

Browser simulation with temporary files, not a real Bash process. Tool versions and app launches are examples. Rerunning or reloading resets this box.

adventurer@newworld:~$

Watch the prompt as much as the output: it shows your current folder after every move, with ~ standing for home. Three things to take from the drill. cd .. twice from room-a lands in dungeon, because each .. is exactly one step up. cd floor-2/boss-room from dungeon is a relative path that goes down two branches at once; the same two words would fail from anywhere else. And the long cd ~/Desktop/... line is an absolute path, so it works from home, from the root, from inside another dungeon entirely. cd - then takes you back to wherever you were, and a bare cd is the same as cd ~. See how . is here and .. is up? That is the whole trick. Once you have it, you can navigate anywhere.

Walkthrough 2: the ls superpowers and the small tools. Start at home, look at it properly, then build the filesystem-quest folder you will search in a moment.

SHyou type
cd ~lsls -als -lamkdir -p filesystem-quest/maps filesystem-quest/loot filesystem-quest/enemiestouch filesystem-quest/maps/world-map.txt filesystem-quest/maps/dungeon-map.txt filesystem-quest/loot/gold.txt filesystem-quest/loot/sword.txt filesystem-quest/loot/shield.txtecho "HP: 10, Attack: 2, Weakness: everything" > filesystem-quest/enemies/slime.txtecho "HP: 30, Attack: 8, Weakness: fire" > filesystem-quest/enemies/goblin.txtecho "HP: 500, Attack: 50, Weakness: none" > filesystem-quest/enemies/dragon.txtls -l filesystem-quest/enemiesls -lh filesystem-quest/enemiesls -lS filesystem-quest/enemiesls -R filesystem-questhead -1 filesystem-quest/enemies/dragon.txtwc filesystem-quest/enemies/goblin.txtwc -l filesystem-quest/enemies/*.txtcp filesystem-quest/enemies/slime.txt filesystem-quest/enemies/blue-slime.txtmv filesystem-quest/enemies/blue-slime.txt filesystem-quest/enemies/king-slime.txtls filesystem-quest/enemiesrm filesystem-quest/enemies/king-slime.txtls filesystem-quest/enemiesman ls
Shell simulatoradventurer@newworld · simulated bashnot run yet

Browser simulation with temporary files, not a real Bash process. Tool versions and app launches are examples. Rerunning or reloading resets this box.

adventurer@newworld:~$

The first three ls lines are the lesson in miniature: plain ls shows five folders; ls -a adds ., .. and three dot-files that were there all along; ls -la shows each with its type, permissions, owner, size and date. Then the enemy files: ls -l gives you three ordinary files of 34 to 40 bytes, -lS reorders them biggest first, and -R walks the whole quest. wc reports lines, words and characters, and wc -l with a glob counts every text file in the folder at once and totals them. cp makes a second slime, mv renames it, rm removes it; ls between each step confirms what happened. The man ls at the end is a shortened page; the real one is longer and leaves with q.

Walkthrough 3: pipes and redirection. Same folder, now searched and logged. Read each line as a sentence before the output arrives: list everything, keep the text files; show my history, keep the mkdir lines; print the dragon file, count its lines.

SHyou type
cd ~mkdir -p filesystem-quest/enemies filesystem-quest/mapscd filesystem-questecho "HP: 10, Attack: 2, Weakness: everything" > enemies/slime.txtecho "HP: 30, Attack: 8, Weakness: fire" > enemies/goblin.txtecho "HP: 500, Attack: 50, Weakness: none" > enemies/dragon.txttouch notes.md todo.txtls -lals -la | grep ".txt"history | grep "mkdir"cat enemies/dragon.txt | wc -lgrep "fire" enemies/goblin.txtgrep -i "weakness" enemies/slime.txtgrep -r "fire" enemies/cat enemies/*.txt | grep "fire"grep "fire" enemies/*.txtls -la > file-list.txtls -la | grep ".txt" > text-files.txtcat text-files.txtecho "=== Session Log ===" > session-log.txtecho "Date: $(date)" >> session-log.txtecho "User: $(whoami)" >> session-log.txtecho "Location: $(pwd)" >> session-log.txtecho "Files here:" >> session-log.txtls -la >> session-log.txtcat session-log.txtls -lR . > maps/inventory-report.txthead -4 maps/inventory-report.txt
Shell simulatoradventurer@newworld · simulated bashnot run yet

Browser simulation with temporary files, not a real Bash process. Tool versions and app launches are examples. Rerunning or reloading resets this box.

adventurer@newworld:~$

Two moments to slow down on. First, the two ways of asking which enemy is weak to fire. cat enemies/*.txt | grep "fire" glues all three files into one stream and finds the line, but it cannot tell you which file the line came from, because by the time grep sees the text the filenames are gone. grep -r "fire" enemies/, or grep "fire" enemies/*.txt, hands grep the files themselves, so it prints enemies/goblin.txt: in front of the hit. When you want to know where, give grep the files; when you only want the lines, pipe.

Second, the session log. Six lines, one > and five >>, and three of them use $(...) to drop the output of date, whoami and pwd into the text. The last >> appends an entire ls -la listing. This is a shell script written one line at a time, and it is exactly how you will write real ones in Session 1.4. Pipes and redirection are where the terminal starts to feel like a superpower: small commands that each do one thing, chained together like combo attacks.

Walkthrough 4: permissions and chmod. Every file carries a small table of who may do what with it. Three groups: the owner (u), the file's group (g), and others (o), everyone else. Three permissions per group: read (r, see the contents), write (w, change it) and execute (x, run it as a program). That table is the nine characters after the type in ls -l.

Top, the string -rw-r--r-- split into a type box and three triads labelled owner, group and others with their meanings, plus a key for r, w, x and dash; bottom left, the chmod +x story: ./quest-start.sh gives Permission denied, chmod +x turns -rw-r--r-- into -rwxr-xr-x with the three x highlighted, and the script runs; bottom right, the number system r=4 w=2 x=1 with 755, 644 and 700 explained
Fig 5 · Who may read, write and run: owner, group, others, three letters each. A new file is never executable; Permission denied on your own script means chmod +x has not happened yet.

-rw-r--r-- is the most common string you will see: a plain file the owner can read and write, that the group and everyone else can only read, and that nobody can run. A brand-new file always looks like this, including a script you just wrote, which is why the first run of any script fails. chmod changes the mode. chmod +x script.sh adds execute permission for everyone; chmod u+x script.sh adds it for the owner only. The numeric form you will meet in tutorials adds r=4, w=2, x=1 per group: 755 is rwxr-xr-x, the normal mode for scripts and folders; 644 is rw-r--r--, the normal mode for files; 700 is private. Learn +x today; the numbers can wait until a tutorial hands you one.

SHyou type
cd ~mkdir -p filesystem-quest/enemiescd filesystem-questtouch enemies/slime.txt enemies/goblin.txt enemies/dragon.txtls -la enemies/touch quest-start.shecho '#!/bin/bash' > quest-start.shecho 'echo "=== QUEST LOG ==="' >> quest-start.shecho 'echo "Adventurer: $(whoami)"' >> quest-start.shecho 'echo "Location: $(pwd)"' >> quest-start.shecho 'echo "Date: $(date)"' >> quest-start.shecho 'echo "Enemies in area:"' >> quest-start.shecho 'ls enemies/' >> quest-start.shecho 'echo "=== END LOG ==="' >> quest-start.shcat quest-start.sh./quest-start.shls -la quest-start.shchmod +x quest-start.shls -la quest-start.sh./quest-start.shchmod 644 quest-start.shls -l quest-start.shchmod 755 quest-start.shls -l quest-start.sh
Shell simulatoradventurer@newworld · simulated bashnot run yet

Browser simulation with temporary files, not a real Bash process. Tool versions and app launches are examples. Rerunning or reloading resets this box.

adventurer@newworld:~$

Read the story in order. The script is written with echo lines in single quotes, which matters: single quotes stop the shell from running $(whoami) now, so the words land in the file untouched and run later, when the script does. cat shows the file is exactly what you meant. ./quest-start.sh (the ./ means "the one in this folder") fails with Permission denied, and ls -la shows why: -rw-r--r--, no x anywhere. chmod +x and the string becomes -rwxr-xr-x, three x, one per group. The same command now runs and prints a log with your name, your location, the date and the enemy list. The last four lines show the numeric form doing the same thing: 644 takes the x away, 755 puts it back.

The first line of the script, #!/bin/bash, is called the shebang. It tells the system which program should read the file. Session 1.4 introduces a setup script, and 1.5 takes it apart; today the point is the lock and the key.

Where it breaks#

Your turn#

The quest#

By the start of Session 1.3, have on your machine:

  • filesystem-quest, with the three enemy files written, maps/inventory-report.txt generated by ls -lR, and an executable quest-start.sh that prints the quest log when you run it.
  • explorers-journal, built to the tree, with notes, the commands list, a discoveries.txt made with pipes, grep-results.txt, and two scripts that run after chmod +x.
  • One sentence in day-02/notes.txt, in your own words, explaining the difference between an absolute and a relative path. If you can write that sentence, you own today.

Next session opens explorers-journal and turns it into a Git repository, so it must exist, and it must be in your home directory under that exact name.

Side quests#

Two pages in the library look further down roads you walked today. They are written for later units, so read the opening and the first picture, not the code.

Side quests from this session

  • Depth-First Tree Traversals`ls -R` and `grep -r` walk the filesystem the way this page walks a tree: into a folder, through everything under it, back up, next folder. That order has a name, depth-first, and you will write it yourself in Unit 9; today just recognise the shape in the first picture.
    Data Structures
  • A01:2025 Broken Access ControlOwner, group, others and read, write, execute is the oldest access-control model in computing, and *Broken Access Control* is the number-one web vulnerability for the same reason `chmod 777` is a bad habit: someone could do something they should not have been allowed to. Read the opening; the code is for Unit 7.
    Security

Before next session#

Finish the Explorer's Journal if you did not finish it here; budget ninety minutes to two hours. The folder must exist before Session 1.3.

Then make the status screen a reflex. Every time you open a terminal while you practise, before you do anything else: pwd, ls -la. Where am I, what is here. Ten seconds. After a week you will do it without deciding to.

Next time: Save Points and Respawns. Git. Every file you have made so far exists in exactly one place, and one careless rm or one broken edit loses it. Git gives you save points: snapshots of a whole folder you can go back to, branches you can experiment on without fear, and a way to merge the experiment back when it works. You will never lose your work again. This changes everything.

You now have a full status screen. You know where you are, what is around you, who owns it, and how to get anywhere. When you arrived, you had a blinking cursor. That is a massive level up.

See also