The basic command to move between folders

To change directory at the command prompt, type cd followed by a space and the name or path of the folder you want to enter. On Windows, the command is cd foldername. On Mac or Linux, it is the same: cd foldername. Press Enter after you type the command.

If the folder name has spaces in it, wrap the name in quotation marks. For example: cd "My Documents". Without the quotes, the command prompt will stop reading after the first space and look for a folder called "My" instead.

You can also use the full path to a folder instead of just the folder name. A path tells the command prompt exactly where the folder is located on your computer. On Windows, a full path looks like C:\Users\YourName\Documents\Projects. On Mac or Linux, it looks like /Users/YourName/Documents/Projects. Type cd followed by the full path, and you will jump directly to that folder.

Key Takeaways

  • The cd command moves you into a different folder; type cd foldername and press Enter.
  • Use quotation marks around folder names that contain spaces, such as cd "My Documents".
  • You can navigate using just a folder name if you are already in the parent folder, or use a full path to jump anywhere on your computer.
  • On Windows, paths use backslashes and start with a drive letter like C:; on Mac and Linux, paths use forward slashes and start with a forward slash.
  • Type cd .. to move up one level to the parent folder, or cd \ on Windows or cd / on Mac and Linux to go to the root directory.

Moving up to the parent folder

To go back up one level to the folder that contains your current folder, type cd .. (that is two periods with no space between them). This is useful when you have navigated several levels deep and want to back out without typing a full path.

You can chain these together to move up multiple levels at once. For example, cd ..\.. on Windows or cd ../.. on Mac and Linux will move you up two levels. Each pair of periods represents one level.

Navigating with absolute and relative paths

A relative path is a path that starts from where you are right now. If you are in C:\Users\YourName and you type cd Documents\Projects, the command prompt looks for a Documents folder inside your current location, then a Projects folder inside that.

An absolute path starts from the root of your drive and works the same way no matter where you are. On Windows, an absolute path always starts with a drive letter like C:. On Mac and Linux, it always starts with a forward slash. If you type cd /Users/YourName/Documents/Projects on Mac, you will end up in the Projects folder regardless of which folder you were in before.

Absolute paths are more reliable when you are writing scripts or instructions for someone else, because they work the same way every time. Relative paths are faster when you are navigating manually and already know where you are.

Checking where you are right now

Before you change directories, it helps to know which folder you are currently in. On Windows, type pwd (print working directory) or simply look at the command prompt itself — it usually shows your current path. On Mac and Linux, type pwd to see the full path of your current folder.

You can also type dir on Windows or ls on Mac and Linux to list all the folders and files in your current location. This shows you what folders you can move into using a relative path.

Switching drives on Windows

On Windows, if you want to move to a folder on a different drive (such as from C: to D:), you must do two things. First, type the drive letter followed by a colon, like D:, and press Enter. This switches to that drive. Then type cd followed by the folder path on that drive.

If you try to use cd alone to jump to a different drive, it will not work. You must switch the drive first, then navigate to the folder you want.

Common mistakes and how to fix them

The most common error is typing a folder name that does not exist or is misspelled. The command prompt will respond with a message like "The system cannot find the path specified." Check the spelling of the folder name and try again. Use dir or ls to see the exact names of folders in your current location.

Another mistake is forgetting quotation marks around folder names with spaces. If you type cd My Documents without quotes, the command prompt thinks you are trying to navigate to a folder called "My" and will fail. Add the quotes and try again: cd "My Documents".

On Windows, using forward slashes instead of backslashes in a path will sometimes cause an error. Use backslashes in Windows paths: C:\Users\YourName\Documents. On Mac and Linux, always use forward slashes: /Users/YourName/Documents.

Frequently Asked Questions

What if the folder name has special characters like parentheses or ampersands?

Wrap the entire folder name in quotation marks, just as you would for spaces. For example: cd "Project (2024)" or cd "Sales & Marketing". The quotes tell the command prompt to treat everything inside as a single folder name.

Can I use cd to navigate to a folder on a network drive or external hard drive?

Yes. On Windows, network drives and external drives appear as drive letters (like E: or Z:) or as paths starting with two backslashes. Switch to that drive first if it is a separate drive letter, then use cd to navigate to the folder. On Mac and Linux, external drives and network locations appear in the /Volumes folder, so you can navigate to them using cd /Volumes/DriveName.

What does the tilde (~) character do in a path?

On Mac and Linux, the tilde represents your home folder. Typing cd ~ takes you directly to your home directory from anywhere. You can also use it in paths: cd ~/Documents/Projects is the same as typing the full path to your home folder plus Documents plus Projects. Windows does not use the tilde in the same way.

How do I go back to the folder I was just in?

On Mac and Linux, type cd - (cd followed by a space and a hyphen) to return to the previous folder. Windows does not have a built-in command for this, so you will need to type the full path or use cd .. to navigate back manually.