🎓 A1Learner
🔍
0 of 50 lessons completed

Shell Paths

A path tells the shell where a file or folder lives. It says where the thing is, step by step.

Absolute path

An absolute path starts at the root. The root is the top folder, written as /.

ls /bin/bash

Relative path

A relative path starts where you are. docs names the docs folder here.

ls docs

Relative from docs

Inside docs, readme.txt names the file there.

cd docs
ls readme.txt

Example

ls /bin/bash
ls docs
cd photos
ls

Key points

  • Path: where a file or folder lives, named step by step.
  • Absolute path: a path that starts at the root.
  • Relative path: a path that starts where you are.
  • Use an absolute path to name a file from anywhere.
  • Use a relative path to name a file near you.

In this example, the first line uses an absolute path for bash. The second line uses a relative path for docs. Then the shell moves into photos. The last line lists it.

Note

The root is the only folder with no parent.

Try it Yourself

Edit the code, then press Run.

Running is simulated

Exercise

Which path starts at the root?