The Windows Command Prompt and PowerShell have transformed how you manage files, programs, and system settings. No more clicking through menus—just type commands to automate tasks, repair issues, or install software quickly. If you’re familiar with Linux or macOS, you’ll recognize these tools as powerful alternatives. If you’re starting fresh, this guide gives you the essentials to start working immediately.
What You'll Need
- Windows 10 (version 1903 or later for modern commands; older versions may require compatibility mode).
- A PC with the latest Windows updates installed.
- Basic familiarity with file locations (e.g., "C:\Users") or willingness to learn.
- Optional: A text editor (like Notepad) to write and save scripts.
Step-by-Step
- Open the Command Prompt: Press Win + R, type cmd, and hit Enter. For PowerShell, repeat but type powershell. If it’s not found: Search for "Command Prompt" in the start menu or use the shortcut Win + S > "cmd" > Open.
-
Switch to a different user account or profile:
Type
exec powershell Start-Process cmd -ArgumentList "/k whoami"to check your current user. If you need to switch, use:runas /user:YourUsername cmd(replace *YourUsername*). Note: Requires admin rights unless you have a dedicated account. If you get an error, run CMD as admin first. -
Verify your current directory:
Type
cdand pressEnter. You’ll see the directory you’re in (e.g.,C:\Users\YourName). To see the full path, typeecho %cd%(older commands) orGet-Location(PowerShell). -
Navigate to a folder:
Use
cd "path\to\folder"(e.g.,cd C:\Downloads). For PowerShell, use forward slashes:cd C:\Downloads. To go up one level, typecd ... -
List files and folders:
Start with
dir(for plain output) ordir /w(wide format) to see files in the current folder. Add/a(all files, including hidden/system) or/s(recursive listing). Example:dir /awill list all files, including.bator.tmpfiles. -
Create a new folder:
Use
mkdir "NewFolderName"(note spaces in the name). For PowerShell, the command is the same. Warning: Avoid spaces in folder names if you later run scripts in CMD. -
Copy and move files:
Copy:
copy "source.txt" "destination"(overwrites if destination exists). To copy multiple files, usecopy *.txt "folder". Move:move "file.txt" "C:\NewLocation". PowerShell usesCopy-ItemandMove-Iteminstead. Warning: Usemove /yto avoid prompt when overwriting. -
Delete files or folders:
Delete a file:
del "file.txt"(faster than "remove"). For multiple files, usedel *.log. Delete a folder:rmdir "folder"(only if empty). Force delete withrmdir /s /q "folder"(PowerShell usesRemove-Item -Recurse -Force). Warning: Deleting folders recursively (/s) removes *everything* inside. -
Search for files:
Use
dir "C:\path\to\folder" /s filename(replace *filename*). For PowerShell, type:Get-ChildItem -Path "C:\path\to\folder" -Recurse -Filter "filename". Tip: Add/bto CMD to get plain text output (e.g.,dir C:\ /s *.txt /b). -
Install a new program or update drivers:
Install from a ZIP: Extract first, then:
cd "extracted_folder"setup.exe /S(suppresses prompts; check the installer’s documentation). Update drivers: Usewmicto find outdated drivers:wmic /namespace:\\root\cimv2\class_ /query "SELECT * FROM Win32_PnPEntity WHERE DriverInstalled = 'False'"(list devices needing updates). For manual updates, usedevmgmt.msc(Device Manager).
Common Mistakes
- Forgetting to close CMD after scripting: Use
exitortype nullto force a clean exit. Scripts may hang if CMD is still open. - Running as admin for every command: Only use admin rights for installation or system changes. Most tasks can run as a standard user.
- Typing incorrect paths: Always use double quotes for spaces in folder names (e.g.,
"Program Files"). For PowerShell, use the parenthesis style:C:\"Program Files". - Overwriting files without confirmation: Use
move /yin CMD or-Forcein PowerShell to skip prompts. - Confusing CMD and PowerShell: Use
echo %PATH%in CMD to check system variables. In PowerShell, type$env:PATH.
Tips
- Use shortcuts: Ctrl + V pastes text into CMD (not just code). Alt + Space opens the window menu in CMD.
- Create a shortcut to CMD/PowerShell: Right-click the desktop > New > Shortcut. Enter
cmdorpowershelland add a shortcut name. - Customize the prompt: Edit
PATHin the system environment variables (System Properties > Advanced > Environment Variables) to add your favorite folder to the PATH. - Teach yourself with online guides: Use
man command_namein PowerShell (e.g.,man dir) to see detailed help. For CMD, search the Microsoft documentation from CMD itself. - Script for automation: Save commands to a text file (e.g.,
backup.bat) and run it withbatch backup.bat. For PowerShell, usepowershell -File script.ps1.
Troubleshooting
-
CMD/PowerShell opens blank or frozen:
- Restart your PC or try a different port (e.g., Win + R > type cmd /k).
- Update Windows (Settings > Update & Security > Windows Update).
- Check the Windows Update (WSUS) status:
net stop wuauserv && net start wuauserv. - If still stuck, use
exitand restart CMD from the start menu.
-
Commands don’t work in one terminal but not others:
- Switch to PowerShell or CMD and type
where command_name(e.g.,where dir) to confirm the command exists. - If missing, update Windows or install the latest Windows updates.
- For PowerShell-specific commands, ensure you’re in the right profile (type
Get-ChildItem $PROFILE).
- Switch to PowerShell or CMD and type
-
Permission denied errors:
- Run CMD/PowerShell as administrator (right-click > Run as admin). For standard users, check if the action is restricted.
- If installing software, use
setup.exe /S(suppress prompts) or check the installer’s documentation. - For folder permissions, use
icacls "folder"(PowerShell) or open Properties > Security tab to adjust.
-
Script runs but does nothing:
- Open a new CMD/PowerShell and type
type script_nameto verify the script exists and has content. - Check for typos in commands or path names.
- Add
pauseto the end of the script to keep it open after execution.
- Open a new CMD/PowerShell and type
Frequently Asked Questions
Why is CMD slower than Windows Explorer?
CMD processes commands in real-time, while Windows Explorer uses a file system browser with visual rendering. For large folders, CMD can be faster for searching or batch operations.
Can I use CMD/PowerShell on Windows 7?
Yes, but Windows 7’s CMD lacks many modern commands (e.g., Get-Location). Use compatibility mode or upgrade to Windows 10/11 for full functionality.
How do I adjust the CMD/PowerShell color scheme?
Use a third-party tool like Windows Terminal (Settings > Apps > Optional Features > Add a feature > Windows Terminal) for custom themes. For pure CMD/PowerShell, edit the theme via registry keys (advanced users only).
What if I get a "command not found" error?
Check if the command exists in your system PATH. Add it manually by editing the PATH variable (System Properties > Advanced > Environment Variables) or download the full Windows SDK for missing tools.
Can I use CMD commands in PowerShell?
Yes, but most commands work the same way. For example, dir in CMD is Get-ChildItem in PowerShell. Use cmd /k to run CMD commands from PowerShell.
How do I backup my CMD/PowerShell history?
Enable history in PowerShell: Set-ItemProperty -Path $PROFILE -Name HistoryWritePreference -Value "WriteToFile". In CMD, history is saved as cmdhist.txt in the current directory.