←
Command Line
/
Guided Lab Move Around with cd
60:00
Click the virtual machine below to start practicing
>_ Tekhnikum | Lab
- Setting up virtual machine…
- Preparing lab files…
- Starting terminal services…
This lab machine has stopped
Your progress through the guide is saved. Start a fresh machine to keep practicing.
Introduction
cd (change directory) moves your shell around the tree. This lab's ~/project contains:
project/
├── Documents/letters/
└── Pictures/
├── Hawaii/
└── Japan/
This lab is the hands-on companion to the cd (Change Directory) lesson from Linux Journey (CC BY-SA 4.0).
Relative Moves
A path that doesn't start with / is relative: it's looked up from where you are now.
cd Pictures
cd Hawaii
pwd
Stay in Hawaii and click Continue.
Sideways with ..
.. means "the directory above". You can use it inside a longer path to step up and across in one move:
cd ../Japan
pwd
/home/learner/project/Pictures/Japan
. means "this directory", so cd . goes nowhere.
Absolute Paths
A path that starts with / is absolute: it works the same from anywhere.
cd /home/learner/project/Documents/letters
pwd
Shortcuts
cd - jumps back to the previous directory and prints it.
cd ~ (or plain cd) goes to your home directory.
cd -
cd ~
pwd
/home/learner
Summary
You can move anywhere in the filesystem.
- Relative paths start from where you are; absolute paths start with
/.
.. is the parent directory and . is the current one.
cd - goes back; cd or cd ~ goes home.