How to change directory
Overview
cd (also written chdir) displays or changes the current directory used by commands.
An absolute path starts from a drive root. A relative path starts from the current folder; .. means its parent and . means the current folder.
- Run
cdwith no path to print the current folder. - Tab completion can finish folder names and add quotes where needed.
pushdremembers your location andpopdreturns to it.
Commands to try
Type each command at the prompt, then press Enter. Replace sample names and paths with ones that exist on your computer.
Commands are generally not case-sensitive, but preserving the spelling shown here makes scripts easier to read.
cd
cd /d "%USERPROFILE%\Documents"
cd ..
cd \
pushd "%TEMP%"
popd
Useful options and details
Options change how a command behaves. Add spaces exactly as shown, and use the command's built-in help when an option is unfamiliar.
A path containing spaces must be enclosed in double quotes, such as "C:\My Files".
/dchanges the drive and directory together.cd \goes to the current drive's root.- Typing
D:switches to drive D's remembered directory;cd /d D:\pathis clearer.
Tips and common mistakes
Check the current folder and read the command output before assuming an operation succeeded.
Practice with disposable files first. Commands that delete, overwrite, or stop a process may not offer an Undo button.
- The prompt may appear unchanged if you try to change to another drive without
/d. - A path is not a command; use
cdbefore it. - Avoid working in
C:\Windowsor application folders while practicing.
Safe practice
Create a temporary practice folder under your user profile so the examples cannot affect Windows system files.
After each command, inspect the result with dir or another read-only command before continuing.
- Move to your profile, then into a known subfolder.
- Go to the parent and return with
pushd/popd. - Use
cdto verify every location.