Moving around

Three tiny commands, `pwd`, `ls` and `cd`, get you anywhere.

Your files live in a tree of folders. At any moment the terminal is "standing" in one folder, called the working directory. These three commands are your map and compass.

  • pwd: print working directory. Where am I?
  • ls: list what's in this folder.
  • cd folder: change directory. Walk into a folder.

Handy shortcuts

  • cd .. goes up one folder.
  • cd ~ (or just cd) goes to your home folder.
  • cd - jumps back to where you just were.

Paths can be absolute (start at the root, like /Users/sam/projects) or relative (start from where you are, like projects/site). Relative paths are shorter, so you'll use them most.

Quick check

You are in ~/projects/site and run cd ... Where do you end up?

  1. ~
  2. ~/projects
  3. ~/projects/site/..
  4. Nowhere, it errors

Answer: ~/projects. .. always means the parent folder, so you step up from site to projects.