Beginner · 8 min · practise every command in the built-in terminal

cd — Change Directory

cd moves you from one directory to another.

Basic usage

cd documents           # Go to the documents directory
cd /etc                # Go to /etc (absolute path)
cd ~                   # Go to your home directory
cd ..                  # Go up one level (parent directory)
cd ../..               # Go up two levels
cd -                   # Go back to previous directory

Navigation shortcuts

ShortcutMeaning
~Your home directory
.Current directory
..Parent directory
-Previous directory

Tab completion

Press Tab to auto-complete directory names:

cd doc[TAB]  →  cd documents/

This saves enormous amounts of typing!

Practical examples

pwd                    # See where you are
cd documents           # Enter documents
pwd                    # Now you're in ~/documents
cd ..                  # Go back up
pwd                    # Back in ~

Practice tasks

  1. Go into the documents directory
  2. Go back to your home directory
  3. Navigate to /var/log and then come back home
  4. From documents, go up two directory levels in one command
  5. Return to the previous directory using the cd shortcut

Commands in this lesson

Navigation