Windows Command Prompt is your powerhouse for system tasks, file management, and troubleshooting without needing a graphical interface. It’s built into Windows and works instantly—no extra setup required. This guide covers the most useful commands, from basic file navigation to advanced system checks, with clear steps and real-world examples.

What You'll Need

  • A Windows PC with Command Prompt open (press Win + R, type cmd, and hit Enter).
  • Basic familiarity with Windows paths or folders (like "Documents" or "C:\").
  • Administrator privileges for some commands (not all require them).
  • Your Windows username and password if prompted.

Step-by-Step: Key Command Prompt Commands

  1. Open Command Prompt
    1. Press Win + S, type cmd, and hit Enter.
    2. Alternatively, right-click on Start or the taskbar and select Windows Terminal (Admin) if you need admin rights.

    You’ll see the prompt start with C:\> or D:\>—this is your current directory.

  2. Navigate Files and Directories
    1. Change directory (cd)
      1. Move up one folder: cd ..
      2. Move to a specific folder (replace "MyDocs" with a real folder name): cd MyDocs
      3. Go to a system folder (use backslashes or forward slashes): cd C:\Windows or cd /Windows
    2. List files in current directory: dir
  3. List files with details (size, date, type): dir /a or dir /w (wide format).
  • View System Information
    1. Check disk space: wmic logicaldisk get size,freespace,caption (shows which drive is which).
    2. View CPU, RAM, and OS info: systeminfo (outputs a detailed report).
    3. Check installed programs (for admin users): wmic product get name,version,caption.
  • Manage Files and Folders
    1. Copy/move files: copy sourcefile.txt destinationfolder\ (for files). move sourcefile.txt destinationfolder\ (for renaming/moving).
    2. List hidden files: attrib +h filename.txt (to hide a file) or attrib -h filename.txt (to reveal it).
    3. Delete files: del filename.txt. Confirm with yes if prompted.
    4. Rename a folder: ren oldfoldername newfoldername.
  • Basic System Commands
    1. Restart or shut down: shutdown /r /t 0 (restart immediately). shutdown /s /t 0 (shutdown immediately). shutdown /a (cancel a pending restart/shutdown).
    2. Check network connection: ipconfig (shows IP, DNS, gateway). ping google.com (tests connectivity).
    3. Update Windows (for admin users): wuauclt /upn DA (checks for updates). wbadmin start command -channel Canary -noInteractive (manual update).
  • Advanced Commands
    1. Find files by name (case-sensitive): findstr "searchterm" *.txt (searches all .txt files for "searchterm").
    2. Redirect output (e.g., save a command’s results to a file): dir > myfiles.txt (saves the list of files to myfiles.txt).
    3. Run a command in another directory: cd C:\Windows && dir (changes to Windows folder then lists files).
    4. Check disk space usage: df -t (lists all drives and free space).
  • Common Mistakes

    • Typing the wrong path: Use forward slashes (/) for portability, or backslashes (\) if you’re in a Windows folder. Example: cd C:\Users\YourName\Documents. Avoid typos—Windows won’t correct them.
    • Running admin commands without admin rights: Some commands (like updating Windows or deleting system files) require admin privileges. If you get an error, right-click the Command Prompt icon and select Run as administrator.
    • Overwriting files without confirmation: Commands like del or copy won’t prompt if the destination is the same as the source. Always double-check paths!
    • Ignoring special characters: Use quotes for filenames with spaces or special characters, e.g., copy "My File.txt" \. Without quotes, Windows may treat the space as a separator.
    • Using incorrect command syntax: For example, dir *.* lists all files, but dir * lists only files with extensions you’ve already seen. Always verify the exact command format.

    Tips

    • Use tabs to autocomplete: Type a command partially (e.g., cd C:\), then press the Tab key to fill in the rest automatically.
    • Save frequently used commands: Copy commands you use often into a text file (e.g., notepad commands.txt) and open it with Command Prompt by pasting the path: type commands.txt.
    • Start with simple commands: Master dir, cd, and ipconfig first—they’re the foundation for everything else.
    • Check for typos early: If a command fails, check for typos or missing spaces. For example, dir /a (with a space) lists all files, but dir/a (no space) will fail.
    • Use aliases for common tasks: Windows allows you to create shortcuts (aliases) for commands. For example, type alias df="df -t" to replace df with df -t in your environment.
    • Enable command history: Press Ctrl + V to paste the last command, or Ctrl + R to search history (requires enabling in settings).

    Troubleshooting

    If a command doesn’t work, try these steps in order:

    1. Double-check your path: If you get an error like Access is denied, ensure you’re in the correct folder or have admin rights. For example, if you try to delete a system file (like C:\Windows\System32\config\systemprofile\Desktop\file.txt), you’ll need admin privileges.
    2. Run the command as administrator: Right-click Command Prompt > Run as administrator for admin-only commands.
    3. Restart Command Prompt: Press Ctrl + C to cancel the command, then close and reopen Command Prompt.
    4. Check for typos: If a command fails with Syntax error, re-read the command and verify spaces, slashes, or extensions.
    5. Use the full path: If you’re unsure about a folder, navigate to it first (e.g., cd C:\ > cd Users\YourName\Documents) before running a command.
    6. Update Command Prompt: If the prompt itself isn’t working, try running Command Prompt from the Start menu (right-click > Run as administrator) to test.
    7. Reset environment variables (advanced):
      1. Open Settings > System > About > Advanced system settings > Environment Variables.
      2. Find System variables, click Edit, then New to add a variable for your commands.
      3. Restart Command Prompt to test.

    If none of these work, the issue might be with your system files. Try creating a new user account (Settings > Accounts > Family & other users) and testing the commands there.

    Frequently Asked Questions

    Q: What’s the difference between cmd and powershell?

    Command Prompt (cmd) uses simple text commands (like dir or ipconfig), while PowerShell (powershell) is more advanced, supports scripting, and offers object-based syntax. For most beginners, cmd is sufficient.

    Q: How do I clear the Command Prompt history?

    Press Shift + Delete in Command Prompt to clear the history immediately. To prevent history from being saved on startup, open Command Prompt > type setx /m PATH "C:\Windows\System32\cmd.exe /K echo off" (this disables history for all users).

    Q: Can I use Command Prompt to fix a frozen Windows update?

    Yes! Try these steps:

    1. Open Command Prompt as admin.
    2. Type wmic os describe to check the Windows version.
    3. For stuck updates, run: net stop wuauserv (stops the update service) net stop cryptSvc net stop bits ren C:\Windows\SoftwareDistribution SoftwareDistribution.old ren C:\Windows\System32\catroot2 catroot2.old net start wuauserv net start cryptSvc net start bits
    Restart your PC afterward. If issues persist, reinstall the Windows Update service via Settings > Update & Security > Recovery > Restart now to open Command Prompt.

    Q: How do I reset Command Prompt to default settings?

    If Command Prompt is misbehaving (e.g., broken shortcuts or missing commands), reset it by replacing the file:

    1. Open File Explorer, navigate to C:\Windows\System32.
    2. Right-click cmd.exe > Properties > Details tab > copy the shortcut path.
    3. Replace C:\Windows\System32\cmd.exe with the original from C:\Windows\System32\cmd.exe.bak (if it exists) or download cmd.exe from Microsoft’s official site (not from third parties).

    Warning: Incorrect replacements can break your system—use this only if you’re confident!

    Q: Why does dir show only 10 files by default?

    By default, dir displays only 10 files per screen. To change this:

    1. Type dir /w (wide) for 30 files.
    2. Or set a custom limit with a batch file: @echo off set COUNT=20 dir /b /a-d | find /c /v "" > temp.txt for /f "usebackq delims=" %%a in ("temp.txt") do ( set /a COUNT=%%a if %COUNT% lss 10 (goto :end) ) :end dir /b /a-d Save this as a .bat file and run it.

    For permanent changes, modify the registry (use a backup first!) or edit the system environment variables.

    Q: How do I find hidden system files with Command Prompt?

    Hidden files in Windows are marked with +h. To list all hidden files:

    1. Navigate to the folder (e.g., cd C:\Windows).
    2. Run: dir /a (shows hidden and system files).

    To hide files again, use: attrib -h filename.

    Q: Can I use Command Prompt to recover a deleted file?

    No, Command Prompt alone cannot recover deleted files—it only works with existing files. For recovery:

    1. Use tools like Recuva (free) or TestDisk.
    2. If the file was deleted from a system folder (e.g., C:\Windows\System32), you may need to restore from a backup.

    Command Prompt can help verify if the file was recently deleted by checking disk space, but it won’t restore it.

    For more advanced file recovery, consider professional software or cloud backups.