The cd command changes your current folder in PowerShell
To change directories in PowerShell, type cd followed by the path to the folder you want to enter. For example, cd C:\Users\Documents moves you into your Documents folder. PowerShell then shows your new location in the prompt, usually displayed as PS C:\Users\Documents>.
The cd command works the same way in PowerShell as it does in older command-line tools, but PowerShell also accepts alternative commands that do the same thing. Understanding which command to use and how to write paths correctly will save you time when navigating your file system from the terminal.
Key Takeaways
- Use cd followed by a folder path to move into that directory, and PowerShell will display your new location in the prompt.
- Type cd .. to move up one folder level, or cd \ to jump to the root of your current drive.
- Paths with spaces must be wrapped in quotes, such as cd "C:\Program Files", or PowerShell will misread the command.
- The Set-Location command does exactly what cd does and works identically in PowerShell.
- Use pwd to display your current directory if you lose track of where you are in the file system.
Basic syntax for the cd command
The simplest form is cd followed by a space and the path. If you want to move to C:\Users\YourName\Downloads, type exactly that: cd C:\Users\YourName\Downloads and press Enter. PowerShell moves you there and updates the prompt to show your new location.
Paths can be absolute (starting from the root of a drive, like C:\) or relative (starting from where you currently are). A relative path like cd Documents moves you into a Documents folder inside your current directory. An absolute path like cd C:\Windows\System32 takes you there regardless of where you started.
Handling paths with spaces and special characters
If a folder name contains spaces, wrap the entire path in double quotes. For example, cd "C:\Program Files" enters the Program Files folder correctly. Without the quotes, PowerShell reads the space as a separator and treats Program and Files as two separate commands, which causes an error.
Other special characters like parentheses or ampersands also require quotes. If you are unsure whether a path needs them, adding quotes around the whole path never hurts and is often the safest approach. You can also use backticks (`) to escape individual special characters, but quotes are simpler and more readable.
Moving up directories and to the root
Type cd .. to move up one level to the parent folder. If you are in C:\Users\YourName\Documents\Work, running cd .. takes you to C:\Users\YourName\Documents. You can chain multiple .. to go up several levels at once: cd ..\..\ moves up two folders.
To jump to the root of your current drive, type cd \. This takes you to C:\ if you are on the C drive. To switch to a different drive entirely, type the drive letter followed by a colon, such as D:, and PowerShell moves to the root of that drive.
Using Set-Location as an alternative
Set-Location is PowerShell's native command that does exactly what cd does. Type Set-Location C:\Users\Documents and it behaves identically to the cd version. Many PowerShell users prefer cd because it is shorter and more familiar, but both work the same way.
PowerShell also accepts chdir as another alias for the same command. All three — cd, Set-Location, and chdir — change your current directory. Choose whichever you find easiest to type and remember.
Checking your current directory
If you lose track of where you are, type pwd (print working directory) and press Enter. PowerShell displays your full current path. This is useful when you have multiple PowerShell windows open or after running several commands in a row.
You can also look at the prompt itself, which usually shows your current directory. The default PowerShell prompt displays PS C:\YourCurrentPath>, so you can often see where you are without typing anything extra.
Common mistakes and how to fix them
The most frequent error is forgetting quotes around paths with spaces. If you type cd C:\Program Files without quotes, PowerShell returns an error saying the path does not exist. Add quotes and try again: cd "C:\Program Files".
Another common issue is typing a path that does not exist. If you type cd C:\NonExistentFolder and that folder is not on your computer, PowerShell returns an error. Double-check the spelling and make sure the folder actually exists. You can use dir or ls to list the contents of your current directory and verify folder names before trying to enter them.
If you are trying to navigate to a network location or a path on a different computer, you may need to use the full network path, such as cd \\ServerName\ShareName. This syntax is less common but works the same way as local paths.
Frequently Asked Questions
Can I use forward slashes instead of backslashes in PowerShell?
Yes. PowerShell accepts both cd C:\Users\Documents and cd C:/Users/Documents. Forward slashes are more common in Unix-like systems, but PowerShell understands both formats. Use whichever feels natural to you.
How do I go back to my previous directory?
PowerShell does not have a built-in back button like some shells do, but you can type cd - in some PowerShell versions or use cd $OLDPWD if that variable is set. The most reliable method is to type the full path to the directory you want to return to, or use cd .. to go up one level.
What if the folder name starts with a number or special character?
Wrap the entire path in quotes, just as you would for spaces. For example, cd "C:\123Folder" or cd "C:\@SpecialFolder". Quotes protect the path from being misinterpreted by PowerShell.
Can I use tab completion to finish typing a path?
Yes. Start typing a path and press Tab, and PowerShell will complete the folder name for you. If multiple folders match what you have typed, pressing Tab cycles through them. This is faster than typing the full path and reduces typing errors.