Navigating through folders
With cd you move from folder to folder in the command line, with .. one level up and with ~ back home. After every step the prompt shows you where you are.
See first: The command line
What you will learn
In this lesson you move through the folder tree with commands, and afterwards you can:
- change into a folder with
cd, using a relative and an absolute path - go one level up with
cd ..and into your home folder withcd ~ - check after every move with the prompt,
pwdandlswhere you are and what is there - put folder names that contain spaces in quotation marks
- interpret the error message that appears when there is no folder of that name at that place
After opening, the command line is in your home folder. To work with files
somewhere else, you change to that place, just as you open a folder with a
double click in Explorer or Finder. The command for this is cd, short for
change directory.
One folder down
Give cd the folder you want to change into:
cd Documents
The command prints nothing, but the prompt changes: on Windows it now says
PS C:\Users\anna\Documents>, on the Mac anna@MacBook Documents %. You can
also go down several levels at once by giving a relative path, with \ on
Windows and with / on the Mac:
cd Documents\uni
cd Documents/uni
One level up, and back home
The two dots .. stand for the folder above the current one. cd ..
therefore goes one level up, and cd ..\.. (on the Mac cd ../..) two
levels. With the tilde you get straight back to your home folder from
anywhere:
cd ~
An absolute path leads there from anywhere
With an absolute path you jump directly to a place, no matter where you are at the moment:
cd C:\Users\anna\Documents\uni
cd /Users/anna/Documents/uni
Use your own user name instead of anna. You can find out what it is with
pwd.
Check after every step
At the beginning it pays to check briefly after every cd where you have
ended up: the prompt names the folder, pwd gives the whole path, and ls
shows what is there. This also shows you where you can go next.
If there is no folder of that name at that place, the shell answers with an
error message, and you stay where you were. In PowerShell it reads
Cannot find path 'C:\Users\anna\Dokumente' because it does not exist., on
the Mac cd: no such file or directory: Dokumente. Usually the name is
misspelt, as here, where someone on a German system typed the displayed name
“Dokumente” instead of Documents, or you are not in the folder you thought
you were in.
Folder names with spaces
For the shell, a space separates the command from its arguments. A folder
called My Photos would therefore look like two arguments. Put such names
in quotation marks:
cd "My Photos"
The Tab key does this for you: type cd My and press Tab.
Try it yourself
Here is the same folder tree as in this lesson, with a terminal below it.
Change to Documents\uni with cd, go back with cd .. and cd ~, and jump
with an absolute path. While you type, the tree lights up the way the path
takes. Try cd My Photos without quotation marks as well, and a misspelt name
such as cd Dokumente.
Builds on this
Details
- Level
- Beginner
- Modules
- Digitization and Programming
- In learning paths
- The command line
- Code
4433- Updated
- 2 November 2026
- Status
- published