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, typecmd, 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
- Open Command Prompt
- Press
Win + S, typecmd, and hit Enter. - 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:\> orD:\>—this is your current directory. - Press
- Navigate Files and Directories
- Change directory (cd)
- Move up one folder:
cd .. - Move to a specific folder (replace "MyDocs" with a real folder name):
cd MyDocs - Go to a system folder (use backslashes or forward slashes):
cd C:\Windowsorcd /Windows
- Move up one folder:
- List files in current directory:
dir
- Change directory (cd)
- List files with details (size, date, type):
dir /aordir /w(wide format).
- Check disk space:
wmic logicaldisk get size,freespace,caption(shows which drive is which). - View CPU, RAM, and OS info:
systeminfo(outputs a detailed report). - Check installed programs (for admin users):
wmic product get name,version,caption.
- Copy/move files:
copy sourcefile.txt destinationfolder\(for files).move sourcefile.txt destinationfolder\(for renaming/moving). - List hidden files:
attrib +h filename.txt(to hide a file) orattrib -h filename.txt(to reveal it). - Delete files:
del filename.txt. Confirm withyesif prompted. - Rename a folder:
ren oldfoldername newfoldername.
- Restart or shut down:
shutdown /r /t 0(restart immediately).shutdown /s /t 0(shutdown immediately).shutdown /a(cancel a pending restart/shutdown). - Check network connection:
ipconfig(shows IP, DNS, gateway).ping google.com(tests connectivity). - Update Windows (for admin users):
wuauclt /upn DA(checks for updates).wbadmin start command -channel Canary -noInteractive(manual update).
- Find files by name (case-sensitive):
findstr "searchterm" *.txt(searches all .txt files for "searchterm"). - Redirect output (e.g., save a command’s results to a file):
dir > myfiles.txt(saves the list of files to myfiles.txt). - Run a command in another directory:
cd C:\Windows && dir(changes to Windows folder then lists files). - 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
delorcopywon’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, butdir *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 theTabkey 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, andipconfigfirst—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, butdir/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 replacedfwithdf -tin your environment. - Enable command history: Press
Ctrl + Vto paste the last command, orCtrl + Rto search history (requires enabling in settings).
Troubleshooting
If a command doesn’t work, try these steps in order:
- 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 (likeC:\Windows\System32\config\systemprofile\Desktop\file.txt), you’ll need admin privileges. - Run the command as administrator: Right-click Command Prompt >
Run as administratorfor admin-only commands. - Restart Command Prompt: Press
Ctrl + Cto cancel the command, then close and reopen Command Prompt. - Check for typos: If a command fails with
Syntax error, re-read the command and verify spaces, slashes, or extensions. - 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. - 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. - Reset environment variables (advanced):
- Open Settings > System > About > Advanced system settings > Environment Variables.
- Find System variables, click Edit, then New to add a variable for your commands.
- 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:
- Open Command Prompt as admin.
- Type
wmic os describeto check the Windows version. - For stuck updates, run:
net stop wuauserv(stops the update service)net stop cryptSvcnet stop bitsren C:\Windows\SoftwareDistribution SoftwareDistribution.oldren C:\Windows\System32\catroot2 catroot2.oldnet start wuauservnet start cryptSvcnet start bits
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:
- Open File Explorer, navigate to
C:\Windows\System32. - Right-click
cmd.exe>Properties>Detailstab > copy the shortcut path. - Replace
C:\Windows\System32\cmd.exewith the original fromC:\Windows\System32\cmd.exe.bak(if it exists) or downloadcmd.exefrom 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:
- Type
dir /w(wide) for 30 files. - 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-dSave 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:
- Navigate to the folder (e.g.,
cd C:\Windows). - 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:
- Use tools like
Recuva(free) orTestDisk. - 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.