How to Switch to the D Drive in Windows CMD (When cd Doesn't Work)

Intro

On Windows you sometimes install a program on the D drive instead of C, or need to work on the D drive — for example, if you installed Python on D or need to work with files in a specific folder on D.

CMD where cd doesn't move to the D drive Figure 1. cd doesn't move to the D drive

When you open CMD it references the C drive by default. Using cd .. (to the parent directory) only goes up to the top of the C drive; it won't switch to another drive.

Body & Conclusion

Unlike Linux, the Windows filesystem has an independent root per drive (e.g., C:, D:). Linux, by contrast, starts all filesystems from a single root directory (/).

So to move to the D drive in CMD, type the drive letter with a colon: D:.

CMD switching to the D drive after entering D: Figure 2. Switching to the D drive in CMD

In Figure 2, entering D: at the C:\Users\user> prompt changes it to D:\>.

Reference — the Root Directory of the Linux Filesystem

Moving to the top-level root with cd / on Linux (Ubuntu) Figure 3. The root directory on Linux (Ubuntu)

Figure 3 shows moving to the top-level directory with cd / on Linux (Ubuntu). Keep in mind the structural difference between Windows (per-drive roots) and Linux (a single root /).


See also the Linux counterpart (when a tangled PATH breaks commands) in the same OS-settings category.

Fixing Linux 'command not found' (ls·vi·vim) — Restoring the PATH
When you overwrite PATH on Linux/macOS and basic commands like ls·vi·vim stop working with 'command not found' — check with echo $PATH and restore the base paths (/bin, /usr/bin, etc.) with export PATH, plus how :$PATH preserves the existing paths.
taystudios.com/blog

📦 Migrated from my own Korean blog (my own writing). Original: taehyuklee.tistory.com/21

Share𝕏f

Comments