title | tags | |||||
---|---|---|---|---|---|---|
The `cd` terminal command - Definition, Explanation & Examples |
|
"How do I get out of here?"
The cd
command changes the current working directory (folder), allowing you to move between directories (folders) on the filesystem.

cd
- change directory
cd
stands for change directory.
cd -
: Change to the previous working directory
cd ..
cd ../..
cd ../another-directory
cd -
cd
cd ~
cd /Users/<username>
cd $HOME
cd /
cd ~/Desktop
cd [directoryName]
cd [directoryName/subDirectoryName]
Command | What It Does | Example |
---|---|---|
cd |
Go to home directory | cd β /Users/<username> |
cd ~ |
Go to home directory | cd ~ β /Users/<username> |
cd .. |
Go up one level | From current directory to parent |
cd ../.. |
Go up two levels | From current directory up two levels |
cd - |
Go back to previous directory | Switches between last two directories |
cd / |
Go to root directory | cd / β / |
cd ~/Desktop |
Go to Desktop | cd ~/Desktop β ~/Desktop |
cd ../another-directory |
Go to sibling directory | From one folder to its sibling |
cd "My Documents"
# or
cd My\ Documents