How to navigate in cmd

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

Quick Answer: Navigating the Command Prompt (cmd) in Windows involves using specific commands to move between directories and view their contents. The 'cd' command changes directories, while 'dir' lists files and subdirectories. You can move up a directory with 'cd ..' or go to the root with 'cd \'.

Key Facts

What is the Command Prompt?

The Command Prompt, often abbreviated as 'cmd', is a command-line interpreter application available in most Windows operating systems. It allows users to interact with the operating system by typing commands rather than using a graphical user interface (GUI). This makes it a powerful tool for performing tasks such as file management, system administration, and running scripts.

Basic Navigation Commands

Changing Directories: The `cd` Command

The most fundamental command for navigation is `cd`, which stands for 'change directory'. To move into a subdirectory, you type `cd` followed by the name of the subdirectory.

Example: If you are in the `C:\Users\YourName` directory and want to go into the `Documents` folder, you would type:

cd Documents

If the folder name contains spaces, you must enclose it in double quotes:

cd "My Documents"

To move back up one directory level (to the parent directory), you use `cd ..`:

cd ..

To go directly to the root directory of the current drive (e.g., `C:\`), you can use `cd \`:

cd \

To change to a directory on a different drive, you first need to switch to that drive by typing its letter followed by a colon, and then use `cd`.

Example: To move to the `Projects` folder on the `D:` drive:

D:
cd Projects

Listing Directory Contents: The `dir` Command

The `dir` command is used to display a list of all files and subdirectories within the current directory. This is equivalent to opening a folder in File Explorer and seeing its contents.

Example:

dir

The output of the `dir` command typically includes the date and time the files/directories were last modified, their size (for files), and their names.

There are several useful options for the `dir` command:

Viewing the Current Directory: The `cd` Command (without arguments)

Simply typing `cd` and pressing Enter will display the full path of your current working directory.

Creating Directories: The `mkdir` Command

To create a new directory (folder), you use the `mkdir` (make directory) command, or its shorter alias `md`.

Example: To create a new folder named `NewProject`:

mkdir NewProject

Deleting Files and Directories: The `del` and `rmdir` Commands

To delete a file, use the `del` command followed by the filename.

Example: To delete a file named `old_report.txt`:

del old_report.txt

To remove an empty directory, use the `rmdir` command (or its alias `rd`).

Example: To remove an empty directory named `temp_folder`:

rmdir temp_folder

To remove a directory and all its contents (use with extreme caution!), you can use `rd /s`.

Example: To remove the `Backup` directory and everything inside it:

rd /s Backup

Advanced Navigation Tips

Tab Completion

One of the most helpful features for navigation is tab completion. As you start typing a command, filename, or directory name, press the Tab key. The Command Prompt will try to auto-complete the text for you. If there are multiple options, pressing Tab repeatedly will cycle through them. This saves typing and reduces errors.

Wildcards

Wildcards are special characters that can represent one or more other characters. The most common wildcards are:

Wildcards are useful with commands like `dir` and `del`. For instance, `dir *.log` would list all files with the `.log` extension.

Absolute vs. Relative Paths

When specifying a directory or file, you can use either an absolute path or a relative path.

Using `pushd` and `popd`

For more complex navigation, especially within batch scripting, the `pushd` and `popd` commands are useful. `pushd` changes to a directory and also stores the current directory in a special list. `popd` then returns you to the directory that was stored by `pushd`.

Understanding the Prompt

The command prompt itself usually displays your current location, followed by a `>` symbol. For example:

C:\Users\YourName>

This indicates that you are currently in the `C:\Users\YourName` directory.

When to Use the Command Prompt for Navigation

While File Explorer is excellent for everyday browsing, the Command Prompt offers advantages for specific tasks:

Mastering these navigation commands can significantly enhance your efficiency when working with the Windows operating system.

Sources

  1. Command Prompt (Windows Commands) - Microsoft Supportfair-use
  2. Cmd - Windows Command Line - SS64CC-BY-SA-4.0
  3. Command Prompt Basics for Windowsfair-use

Missing an answer?

Suggest a question and we'll generate an answer for it.