Files live in directories (folders), and directories live inside other directories, all the way up to the top one, called root and written /. You are always in one directory: the working directory. Commands look for names there unless you tell them otherwise.
Paths
A path says where something is.
- An absolute path starts with
/and works from anywhere:/home/learner/projects/website. - A relative path starts from where you are: if you're in
/home/learner, thenprojects/websitemeans the same place.
A few names are special:
| Name | Means |
|---|---|
. | this directory |
.. | the directory one level up (the parent) |
~ | your home directory, /home/learner |
Changing directory
cd (change directory) moves you. The prompt changes to show where you are now:
cd projectscd website/csspwdcd ..cd /var/logcdcd .. goes up one level and cd ../.. goes up two. cd on its own always takes you home, and cd - jumps back to the directory you were in before.
Press Tab while typing a name and the shell finishes it for you. It saves typing and typos, and if nothing happens, the name you started doesn't exist where you are.