The cd command moves you 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, then press Enter. On Windows, this works in Command Prompt and PowerShell. On Mac and Linux, it works in Terminal. The folder you move to must exist, and you must have permission to access it.

The command stands for "change directory" and is one of the most basic navigation tools at the command line. Once you move into a folder, any commands you run will affect files in that folder unless you specify a different path.

Key Takeaways

  • Type cd foldername to enter a folder in your current location, then press Enter.
  • Type cd .. to move up one level to the parent folder.
  • Type cd / on Mac and Linux, or cd C:\ on Windows, to jump to the root of your drive.
  • Use the full path like cd C:\Users\YourName\Documents to jump directly to any folder without moving step by step.
  • Type pwd (Mac and Linux) or cd alone (Windows) to see which folder you are currently in.

Moving into a folder one level down

If you are in a folder and you can see another folder inside it, you can move into that folder by typing its exact name. For example, if you are in your home directory and you see a folder called Documents, type cd Documents and press Enter. The command prompt will now show you are inside the Documents folder.

Folder names are case-sensitive on Mac and Linux but not on Windows. If a folder name has spaces in it, wrap the name in quotes: cd "My Folder". If you type a folder name that does not exist, the command prompt will show an error message like "The system cannot find the path specified" on Windows or "No such file or directory" on Mac and Linux.

Moving back up to the parent folder

To move up one level to the folder that contains your current folder, type cd .. (that is two periods with no space between them) and press Enter. Each time you run this command, you move up one level. If you run it repeatedly, you will eventually reach the root of your drive.

You can also move up multiple levels at once by typing cd ..\.. on Windows or cd ../../ on Mac and Linux. Each .. or ../ moves you up one level. For example, cd ../../Documents moves up two levels and then into a Documents folder at that higher level.

Jumping directly to any folder using the full path

Instead of moving step by step, you can jump directly to any folder by typing its full path. On Windows, paths start with a drive letter like C: and use backslashes: cd C:\Users\YourName\Documents. On Mac and Linux, paths start with a forward slash and use forward slashes: cd /Users/YourName/Documents.

If you do not know the full path, you can find it by opening the folder in your file manager and copying the address bar. Then paste it into the command prompt after cd. On Windows, if the path contains spaces, wrap the entire path in quotes: cd "C:\Program Files\My App".

Checking which folder you are currently in

On Mac and Linux, type pwd (print working directory) and press Enter to see the full path of your current folder. On Windows in Command Prompt, type cd alone with no folder name and press Enter. In PowerShell, type pwd just like on Mac and Linux.

The command prompt itself also usually shows your current location. On Windows, it typically shows something like C:\Users\YourName\Documents>. On Mac and Linux, it often shows the folder name or a tilde ~ representing your home directory. If you are unsure where you are, checking with pwd or cd takes one second and prevents mistakes.

Using shortcuts for common folders

On Mac and Linux, the tilde ~ represents your home directory. Type cd ~ to jump there from anywhere. On Windows, you can type cd %USERPROFILE% to jump to your user folder, though most people just type the full path.

On all systems, you can type cd with no arguments (on Mac and Linux) or cd %USERPROFILE% (on Windows) to return to your home directory. These shortcuts save time if you are moving around many folders and want to reset to a known location.

What to do when the folder does not exist or you lack permission

If you type a folder name that does not exist, the command prompt returns an error. Double-check the spelling and capitalization (on Mac and Linux). If the folder name has spaces, make sure it is in quotes. If you are using a path, verify each part of the path exists by navigating step by step.

If the folder exists but you get a "permission denied" or "access is denied" error, you do not have permission to enter that folder. On Windows, you may need to run Command Prompt as Administrator. On Mac and Linux, you may need to use sudo, though this is rarely necessary for folders in your home directory. Contact your system administrator if you believe you should have access.

Frequently Asked Questions

Can I use cd to move to a folder on a different drive on Windows?

Yes, but you must first change to that drive. Type the drive letter followed by a colon, like D:, and press Enter. Then use cd to navigate within that drive. Alternatively, type the full path including the drive letter: cd D:\FolderName.

What is the difference between cd and cd . ?

A single period . represents the current folder. Typing cd . does nothing because you are already there. Two periods .. represent the parent folder, so cd .. moves you up one level. This is a common mistake when learning the command.

How do I see what folders are inside my current folder?

On Windows, type dir and press Enter. On Mac and Linux, type ls and press Enter. Both commands list the contents of your current folder so you can see which folders you can move into with cd.

Can I use cd to move to a network folder or shared drive?

Yes. On Windows, use the full network path: cd \\ComputerName\ShareName. On Mac and Linux, the path depends on how the network drive is mounted. You can usually type cd /Volumes/ShareName on Mac or cd /mnt/ShareName on Linux, depending on your setup.

What happens if I type cd with a folder name that has special characters?

Wrap the folder name in quotes to protect special characters: cd "Folder@Name". On Mac and Linux, you can also escape individual characters with a backslash: cd Folder\@Name. Quotes are usually simpler and work on all systems.