1/10

Moving around · Going places with cd

Change directory

cd (short for change directory) moves you into another folder. From then on that folder is your working directory, so commands like ls work there.

Why: it's how you get around. Most work happens inside one project folder, and you cd there first.

How to type it: cd, a space, then the folder's name.

Worked example

learner@shellstreak:~$ cd projects

What happened

  • No output at all. That's normal: cd works silently, and so do most commands that succeed with nothing to report.
  • Look at the prompt instead. It now reads learner@shellstreak:~/projects$: ~/projects means the projects folder inside your home folder.
  • pwd would now print /home/learner/projects, and ls would list budget and website.

Common mistakes

  • Trying to cd into a file, like cd notes.txt. You can only go into folders: the terminal says Not a directory.
  • Getting the capitals wrong: cd documents fails, because the folder is Documents.
  • Forgetting the space: cdprojects is an unknown command.

Tap Run to move into projects, then try ls there.

Try it:cd projects
learner@shellstreak: ~
Starting your practice shell…

You can also type in the terminal yourself. Try anything: you can't break it.

Go deeper: Basic terminal commands for beginners