AI Hints
Home›Linux Tutorial›Moving Around
Linux · Lesson 16 of 120

cd: Moving Around

Changing folder.

⏱ 2 min read▶ Video at 17:57🎓 Free
Watch this lesson in the Linux courseWatch on YouTube ↗Full Linux course

Looking into folders from outside is useful, but usually you want to go inside them. The CD command does that. It stands for change directory.

cd: Moving Around
From the video: cd: Moving Around
  • Go inside a folder
  • cd does it
  • Change directory

Into a folder, and back

CD Documents moves us into the Documents folder. Look at the prompt. It now says tilde slash Documents. LS shows the files in here, without naming the folder. Then CD dot dot takes us up one level, back to home.

Terminal
cd Documents
ls
cv.txt  report.txt
cd ..
pwd
/home/sam

Going deeper, and straight home

You can go several folders deep in one step, by joining them with slashes. And CD on its own, with nothing after it, always takes you straight back home, wherever you are. It's the quickest way to stop feeling lost.

Terminal
cd /var/log
pwd
/var/log
cd
pwd
/home/sam

When cd fails

If you misspell a folder name, CD just says, no such file or directory, and you stay where you were. Remember, names are case sensitive. Documents with a small d is a different name, so it fails. Tab completion helps you avoid these mistakes.

keyvalue
cd documentsno such file or directory
Whynames are case sensitive
You staywhere you were
Fixuse tab completion

Summary

CD moves into a folder, CD dot dot goes up, and CD on its own goes home. Next, the two kinds of path. Absolute, and relative.

Key takeaways
  • cd <folder>
  • cd ..
  • cd goes home
Next up: Absolute and Relative Paths — two ways to say where