Need quick fixes, file management, or system checks in Windows Command Prompt? Mastering these essential commands transforms basic tasks into fast, reliable workflows—no advanced knowledge required. You’ll need a working Windows PC with an installed Command Prompt (included with Windows 10/11) or any modern desktop OS with a terminal emulator (Linux/macOS have similar `cmd` equivalents like PowerShell or bash). Note: macOS/Linux use different syntax for some commands; on Windows, use `typehelp cmd` or `help` in CMD for OS-specific details.
What You'll Need
- A Windows PC with Command Prompt access (built-in) or a terminal emulator (Linux/macOS).
- Administrator rights for commands like `diskpart`, `netsh`, or `chkdsk` (prompt for them if needed).
- Basic familiarity with file paths (e.g., `C:\Users\YourName\Documents`).
- An internet connection for step 1 (optional but recommended for verifying versions).
Step-by-Step
-
Open Command Prompt
- Windows 10/11: Press
Win + S, typecmd, and hitEnter. For admin access, right-click CMD >Run as administrator. - Linux/macOS: Use your terminal emulator (e.g., Terminal app on macOS, GNOME Terminal on Linux). Example: Open Terminal > type
bashorzsh.
Verify the OS version with
ver(Windows) oruname(Linux/macOS). For Windows, check Windows Update for the latest CMD features (wmic os get captionlists the Windows version). - Windows 10/11: Press
-
Basic Navigation
- Navigate to a folder:
cd C:\NewFolder(Windows) orcd /newfolder(Linux/macOS).cd ~(home directory) orcd ~(Windows).
- List files/folders:
dir(Windows) orls(Linux/macOS). Add-rfor reverse order (newest first).dir /a(Windows) shows hidden/system files.
- Create a folder:
mkdir NewFolder(Windows/Linux/macOS).
- Navigate to a folder:
-
File Management
- Rename a file:
rename OldFile.txt NewFile.txt(Windows). On Linux/macOS:mv OldFile.txt NewFile.txt. - Delete a file/folder:
del File.txt(Windows) orrm File.txt(Linux/macOS). Warning: Userd /s /q(Windows) to delete a folder and its contents *only if empty*. For forceful deletion, typedel /f(Windows) orrm -rf(Linux/macOS)—be extremely careful with-rf. - Copy files:
copy File1.txt File2.txt(Windows) orcp File1.txt File2.txt(Linux/macOS). For folders, usexcopy(Windows) orcp -r(Linux/macOS).
- Rename a file:
-
System Tools
- Check disk space:
wmic logicaldisk get size,freespace,caption(Windows) ordf -h(Linux/macOS). For a specific drive, usediskpart(Windows) orfdisk -l(Linux/macOS). - Check network status:
ipconfig /all(Windows) orifconfig(Linux/macOS). Note yourIPv4 AddressandDNS Servers. - Restart a service (Windows only):
sc start or stop ServiceName(replaceServiceNamewithTaskScheduler,W32Time, etc.). Usesc queryto list services. Alternative: Restart the service via the Services app (services.msc). - Enable/disable a service via PowerShell (Windows):
Enable-NetFirewallRule -DisplayName "TCP - Remote Desktop"(Windows 10/11).
- Check disk space:
-
Networking
- Ping a website:
ping google.com(Windows/Linux/macOS). Add-tfor continuous ping. - Find open ports:
netstat -ano(Windows) shows active connections by port number.- Linux/macOS:
ss -tulnporlsof -i.
- Configure Wi-Fi directly (Windows only):
netsh wlan show networkslists available networks. To connect:netsh wlan connect name="SSID"(replaceSSIDwith your network name).
- Ping a website:
-
Performance Monitoring
- Check CPU temperature and usage:
wmic cpu get LoadPercentage,TemperatureCelsius(Windows). For real-time monitoring, use tools likeHWMonitor.exe(download from Newegg) orsensors(Linux).- Linux/macOS:
lscpufor CPU info.
- View open processes:
tasklist(Windows) ortop(Linux/macOS). Kill a process:taskkill /PID 1234(Windows) orkill 1234(Linux).
- Check CPU temperature and usage:
If That Did Not Work
- Close and reopen Command Prompt. Sometimes CMD hangs or misbehaves. Try opening it as admin again.
- Check for typos. Windows/Linux/macOS commands are case-sensitive. Verify paths (e.g.,
C:\vsC:). - Run in safe mode. Boot into Windows Safe Mode (press
F8during startup) and retry—some malware blocks CMD access. - Update Windows. Open
Settings > Windows Update > Check for updatesand install pending patches. Update your terminal emulator (Linux/macOS) via package managers (e.g.,sudo apt updatefor Ubuntu). - Reinstall CMD. If CMD is corrupted, reinstall via:
- Windows: Use Windows Installation Media or reset to factory settings (
Settings > Update & Security > Recovery > Reset this PC). - Linux/macOS: Reinstall the terminal emulator or shell (e.g.,
sudo apt install --reinstall bashfor Ubuntu).
- Windows: Use Windows Installation Media or reset to factory settings (
Common Mistakes
- Forgetting to add spaces. Example:
dirc:\fails—always usedir C:\. Linux/macOS:ls/cfails; usels /c. - Running forceful commands without confirmation. Windows:
del /fprompts for deletion. Linux/macOS:rm -rfdeletes everything in the current folder—use with extreme caution. - Assuming all commands work in all OSes. Windows
lsbehaves differently from Linux/macOS. Always check syntax for your platform. - Ignoring admin rights. Commands like
chkdskordiskpartrequire admin privileges. If CMD asks for UAC elevation, clickYes. - Using incorrect paths. Example:
cd Documentsfails if your home folder isC:\Users\You. Always use absolute paths likecd C:\Users\You\Documents.
Tips
- Use tabs for autocompletion. Type
cd C:\Users, then pressTabtwice to fillC:\Users\You. Linux/macOS: PressTabafter a command to auto-finish (e.g.,ls -lh+Tabforls -lh). - Save frequently used commands. In Windows CMD, press
Ctrl+Vand paste common scripts. On macOS/Linux, create a.bashrcfile to auto-run commands on startup. - Use `where` or `which` to find executables. Windows:
where notepadlists Notepad paths. Linux:which notepad(usewhich pythonfor Python). - Redirect output to files. Save command output to a text file:
- Windows:
dir > files.txtappends results tofiles.txt. Use2>&1to include errors (e.g.,ping google.com 2>&1 > output.txt). - Linux/macOS:
ls > files.txt(overwrites); use> files.txtto append.
- Windows:
- Learn shortcuts. Windows CMD:
!filenameruns a saved command (e.g.,!checkdiskif you savedchkdsk C: /f).!fileopens a file in Notepad (e.g.,!notesopensC:\notes.txt).
- Use `&&` for sequential commands. Run commands only if the first succeeds:
dir && echo "Folder exists"(Windows). Use;for separate commands regardless of success:dir; echo "This runs anyway". - Enable command history. Windows: Set
history length=1000inautoexec.nt(text file inC:\Windows) to save 1,000 commands. Linux/macOS: Edit.bashrcto enable history expansion (HISTFILESIZE=1000).
Troubleshooting
-
CMD opens blank or frozen
- Close all CMD windows, restart your PC, and open a new one.
- Run
netsh winsock reset(Windows) orsudo sysctl -w net.ipv4.ip_forward=0(Linux/macOS) to reset network settings. - Check Windows Event Viewer for errors:
- Windows:
Settings > Update & Security > View event viewer> search forcommand. - Linux/macOS:
journalctl(Linux) or check/var/log/syslog(macOS).
- Windows:
-
Commands return errors like "Access Denied"
- Run the command as administrator (right-click CMD > "Run as administrator").
- For disk commands (
chkdsk,diskpart), ensure you’re in the correct drive (e.g.,cd C:beforechkdsk C:). - Linux/macOS: Check file permissions with
ls -lh. If you own the file, usesudobefore commands (e.g.,sudo rm file.txt).
-
Ping fails or network tools don’t work
- Restart your router/modem. Wait 1 minute before retrying.
- Check if your firewall is blocking traffic:
- Windows: Open
Settings > Windows Security > Firewalland allowping. - Linux/macOS: Edit firewall rules (e.g.,
sudo ufw allow 53for DNS on Ubuntu).
- Windows: Open
- Verify DNS settings:
ipconfig /all(Windows) orsystemd-resolved --status(Linux). Set a public DNS like8.8.8.8if issues persist.
-
Disk commands fail with "Not enough memory"
- Free up disk space by deleting unnecessary files (use
dir /sto list hidden files). - For
chkdsk, run it on a different drive if C: is full:chkdsk D: /f(Windows). - Linux/macOS: Check disk space with
df -h. Mount an external drive if needed.
- Free up disk space by deleting unnecessary files (use
-
Terminal emulator (Linux/macOS) is unresponsive
- Close all terminal windows and restart your PC.
- Update the terminal emulator:
- Linux:
sudo apt update && sudo apt upgrade(Debian/Ubuntu). - macOS:
softwareupdate --listto check for updates.
- Linux:
-
PowerShell errors appear in CMD
- Use
powershell(without quotes) to run PowerShell commands directly from CMD. Example:powershell Get-ChildItem -Path C:\. - If CMD ignores PowerShell output, enable it in CMD:
- Windows: Type
set PSRemotingEnabled=truein CMD (temporary). For permanency, editC:\Windows\System32\WindowsPowerShell\v1.0\powershell.exeand addPSRemotingEnabled=trueto theif ($host.RunspacesProvider) { $host.RunspacesProvider.DesiredNumberOfThreads = 1 }line.
- Windows: Type
- Use
Frequently Asked Questions
What’s the fastest way to list all hidden files in Windows CMD?
Use dir /a. Add /s to include subfolders: dir /a /s. For a specific folder, navigate there first (e.g., cd C:\ > dir /a).
How do I permanently enable Command Prompt in Windows 11?
Command Prompt is built into Windows 11 by default. If missing, reinstall via Windows Setup Media or reset to factory settings. To ensure access:
1. Open Settings > Apps > Optional Features > Add a feature.
2. Search for Windows Terminal and enable Command Line (if available). For true CMD persistence, create a shortcut in All Apps with target: C:\Windows\System32\cmd.exe.
Can I use CMD commands on Linux/macOS?
Most Windows CMD commands have Linux/macOS equivalents, but syntax differs. For example:
- Windows: dir → Linux/macOS: ls
- Windows: netstat → Linux/macOS: ss or netstat -tulnp
Use man (Linux/macOS) or info for detailed command help. For cross-platform tools, try nmap (network scanning) or curl (HTTP requests).
Why does tasklist show "System Idle Process" using 100% CPU?
This is normal. The System Idle Process is a virtual process that monitors CPU usage for multitasking. If it spikes:
- Check for malware using tasklist /v to look for suspicious processes.
- Run a full system scan with Windows Defender or an antivirus.
- Disable startup programs via msconfig > Startup (Windows).
How do I see detailed CPU information from CMD?
Use wmic cpu get name,numberofcores,numberoflogicalprocessors,loadpercentage,temperaturecelsius for Windows. For Linux/macOS, use:
lscpu (core/thread info) or mpstat -P ALL 1 (real-time stats). Linux/macOS also support htop (install via sudo apt install htop) for interactive CPU monitoring.
What should I do if my CMD session keeps disconnecting?
Possible causes and fixes:
1. **Network instability**: Restart your router and disable VPNs/proxies.
2. **Terminal emulator bug**: Close all CMD windows, restart your PC, then reopen.
3. **Windows settings**: Disable "Enable the virtualization technology" in:
Settings > System > About > Advanced system settings > Hardware > Processor > Virtualization (Turn off) if issues persist.
4. **Driver issues**: Update your motherboard/chipset drivers via devmgmt.msc.
For Linux/macOS, check for terminal emulator crashes by running strace -e openat cmd (replace cmd with your terminal).