Skip to content

Latest commit

 

History

History
98 lines (73 loc) · 3.29 KB

File metadata and controls

98 lines (73 loc) · 3.29 KB

cd

"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.

Click to watch the video 👇

Name

cd - change directory

Mnemonic

cd stands for change directory.

Options

  • cd -: Change to the previous working directory

Examples

Move up one directory

cd ..

Moving up one directory with cd ..

Move up two directories

cd ../..

Moving up two directories with cd ../..

Move to parent folder's sibling directory

cd ../another-directory

Moving to parent folder's sibling directory with cd ../another-directory

Switch back to previous directory

cd -

Switching back to previous directory with cd -

Move the user's home directory

cd
cd ~
cd /Users/<username>
cd $HOME

Moving to user's home directory with cd

Move directly to the filesystem's root directory

cd /

Moving to filesystem's root directory with cd /

Move to a specific directory

cd ~/Desktop
cd [directoryName]
cd [directoryName/subDirectoryName]

Moving to specific directory with cd ~/Desktop

Command Quick Reference

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

Tips

How to Handle Spaces in Directory Names

cd "My Documents"
# or
cd My\ Documents

How to Handle Spaces in Directory Names with cd command