Lesson 3: Moving between directories — cd
We can already see where we are (pwd) and what's around us (ls) — now we learn to move. The command cd ('change directory') takes us from directory to directory, like walking between rooms. We'll picture the filesystem as a tree starting at the root /, and meet two ways to give an address: an absolu
If pwd says 'which room am I in' and ls says 'what's in the room', then cd is walking to a different room. cd .. steps out to the room above you, and cd with a full address jumps straight to a faraway room.
- cd
- Short for change directory — moves you to a different directory. On success it prints nothing (silent).
- filesystem tree
- All directories are arranged like a tree that starts from the root /. Each directory can hold more directories inside it.
- absolute path
- An address that starts from the root /, e.g. /var/log. It works from wherever you are, like a full address.
- relative path
- An address from where you are now, with no leading /. E.g. logs (a directory below us) or .. (the directory above us).
- parent directory (..)
- The directory that contains the current one — one level up the tree. You reach it with cd ..