Skip to the workspace
Pebellslearn by building
Navigation Basics  ›  Lesson

pwd, ls and cd — Finding Your Way

Basic Commands 12 minpwd shows where you are, ls shows what is there, and cd moves you using absolute or relative paths.

linux / pwd, ls and cd — Finding Your Way

Explore each scene at your own pace.

01 · The rule

The rule

pwd, ls and cd — Finding Your Way

You open a terminal and see only a blinking cursor. There are no windows or icons, so you can't glance at a desktop to see where you are. On the command line you ask, and three tiny commands do most of the asking. Throughout this course we'll follow Asha, who keeps her community garden's records in a folder called garden in her home directory.

The rule

Where am I, what is here, go there: pwd, ls, cd.

pwd (print working directory) tells you which folder the shell is "standing in" right now:

$ pwd
/home/asha

ls (list) shows what is inside the current folder, or inside any folder you name:

$ ls
garden  photos  todo.txt
$ ls garden
harvest.csv  notes.txt  plots

Two options you'll use every day:

  • ls -l gives the long listing, with permissions, owner, size and date on each line.
  • ls -a shows all entries, including hidden ones whose names start with a dot, such as .bashrc.

You can combine them: ls -la.

cd (change directory) moves you:

$ cd garden
$ pwd
/home/asha/garden

A path is written one of two ways:

  • Absolute paths start with / and describe the full route from the top of the system: /home/asha/garden.
  • Relative paths start from where you are now: garden, or plots.

A few special names work anywhere:

Name Means
. this directory
.. the parent directory, one level up
~ your home directory
- (with cd) the directory you were in before

A plain cd with nothing after it takes you home.

Scene 1 of 5
Hover to wake the cannons. Drag to move, or use arrow keys when focused. Press Enter to fire a shot.