Mission 2 of 5
Changing Directories and Understanding Paths
Move between known locations and return home without losing your place.
Move around safely using absolute paths, relative paths, home shortcuts, and parent folders.
Mental model
Understand what is happening
Absolute paths start with /.
Relative paths start from where you currently are.
. means here; .. means parent folder.
cd - returns to the previous directory (tracked in $OLDPWD).
Guided lab
Work through the mission
Move to home and back
Moves home, then returns to the sandbox.
cd ~
pwd
cd ~/linux-practice
pwdPractice parent folders
Shows how .. climbs up one level at a time.
cd ~/linux-practice
mkdir -p files/demo
cd files/demo
pwd
cd ..
pwd
cd ../..
pwdReturn to previous directory
cd - switches back to the last directory you were in, without retyping the path.
cd ~/linux-practice
cd /tmp
pwd
cd -
pwdRead-only visit to /etc
Visits Ubuntu configuration folders without editing anything.
cd /etc
pwd
ls -l | head -20
cd ~/linux-practiceCheckpoint
Verify the mission
You can leave the workspace and return using absolute and relative paths.
Try it yourself
One step without a recipe
Navigate into files/demo and back to ~/linux-practice. Write down one absolute path and one relative path.
Need a hint?
When you feel lost, type `cd ~` and hit Enter. Home is your reset button. From there, navigate forward with a clear path. Nobody remembers every absolute path on their first week.
Explain it back
Before you move on
- Which path type starts with /?
- What does cd - do?