How to cd in powershell
Content on WhatAnswers is provided "as is" for informational purposes. While we strive for accuracy, we make no guarantees. Content is AI-assisted and should not be used as professional advice.
Last updated: April 4, 2026
Key Facts
- The primary cmdlet for changing directories is `Set-Location`.
- The common alias for `Set-Location` is `cd`.
- You can use forward slashes (/) or backslashes (\) to specify paths.
- Tab completion is available for directory names and file paths.
- Relative paths (e.g., `cd ..` to go up one directory) and absolute paths can be used.
Overview
Navigating the file system is a fundamental skill when working with any command-line interface, and PowerShell is no exception. While many users transitioning from other shells might be familiar with the `cd` command, PowerShell utilizes a more robust cmdlet system. Understanding how to change directories effectively in PowerShell will significantly improve your productivity and ability to manage files and folders.
Understanding PowerShell's Navigation Cmdlets
PowerShell employs a verb-noun naming convention for its cmdlets, which makes them more descriptive. The cmdlet responsible for changing your current location within the file system (or any other provider, like the registry) is Set-Location. However, for convenience and backward compatibility with traditional command-line users, PowerShell provides a built-in alias for Set-Location, which is commonly known as cd.
Therefore, when you type cd in PowerShell, you are actually executing the Set-Location cmdlet.
Basic Directory Navigation
The most common use case is navigating to a specific directory. You provide the path to the directory as an argument to the cd (or Set-Location) command.
Absolute Paths
An absolute path specifies the location of a file or directory starting from the root of the file system. In Windows, this typically starts with a drive letter (e.g., C:) followed by a colon and then the directory structure.
Example:
To navigate to the 'Documents' folder within your user profile, you would use:
cd C:\Users\YourUsername\DocumentsOr, using forward slashes, which PowerShell often handles more gracefully:
cd C:/Users/YourUsername/DocumentsReplace YourUsername with your actual Windows username.
Relative Paths
Relative paths specify a location relative to your current directory. This is very useful for moving up or down the directory tree without typing the full path each time.
.(dot): Represents the current directory...(dot dot): Represents the parent directory (one level up).
Examples:
If you are currently in C:\Users\YourUsername\Documents and want to go to the Projects subfolder:
cd ProjectsIf you are in C:\Users\YourUsername\Documents\Projects and want to go back to your user profile directory:
cd ..If you are in C:\Users\YourUsername\Documents\Projects and want to go back two levels to the root of the C drive:
cd ..\..Using Tab Completion
PowerShell's tab completion is an invaluable tool for navigating and typing paths. As you start typing a directory name or file path, press the Tab key. PowerShell will attempt to complete the name for you. If there are multiple possibilities, pressing Tab repeatedly will cycle through them. This significantly reduces typing errors and speeds up the process.
Example:
If you are in C:\ and want to go to Users, you can type:
cd UThen press Tab. If there's only one directory starting with 'U', it will complete to Users. If there are others (e.g., Updates), you'll need to type more characters or press Tab again to cycle through.
Navigating Different Providers
It's important to remember that Set-Location (and its alias cd) works not only for the file system but also for other PowerShell providers, such as the registry. You can use Get-PSProvider to see the available providers.
Example: Navigating the Registry
To navigate to the current user's software key in the registry:
cd HKCU:\softwareHere, HKCU: is the PowerShell provider name for the HKEY_CURRENT_USER registry hive.
Tips for Efficient Navigation
- Use
Push-LocationandPop-Location: For complex navigation, you can usePush-Locationto save your current directory onto a stack and then navigate elsewhere.Pop-Locationwill then return you to the directory you saved. This is like bookmarking your location. - Use
Get-ChildItem(orls/dir): Frequently useGet-ChildItem(aliased aslsanddir) to see the contents of your current directory, helping you decide where to go next. - Understand Drive Names: In PowerShell, drives are represented by their names followed by a colon (e.g.,
C:,D:,HKCU:). - Use Quotes for Paths with Spaces: If a directory or file name contains spaces, enclose the entire path in quotes. For example:
cd "C:\Program Files".
By mastering the cd command and its underlying Set-Location cmdlet, you gain a powerful tool for interacting with your computer's file system and other structured data stores within PowerShell.
More How To in Daily Life
Also in Daily Life
More "How To" Questions
Trending on WhatAnswers
Browse by Topic
Browse by Question Type
Sources
Missing an answer?
Suggest a question and we'll generate an answer for it.