CMD Fundamentals
Command Prompt (cmd.exe) is the legacy Windows command-line interpreter. Run as administrator for commands that require elevated privileges: right-click Start → Command Prompt (Admin), or search cmd → right-click → Run as administrator. Key navigation commands: `cd` (change directory), `cd ..` (go up one level), `dir` (list directory contents), `mkdir` or `md` (create directory), `rmdir` or `rd` (remove directory — use /s to remove non-empty), `cls` (clear screen), `exit` (close). Wildcards: `*` matches any characters, `?` matches one character. `dir *.txt` lists all .txt files. Tab completion works in CMD (press Tab to complete file/folder names).
File Management Commands
copy: copies files. `copy source.txt destination.txt`. xcopy: copies files and directory trees. `xcopy C:\source D:\dest /s /e /h` (/s=subdirectories, /e=empty folders, /h=hidden files). robocopy: robust file copy, network-aware, supports retry and mirroring. `robocopy C:\source D:\dest /mir` (mirror). move: moves files. `move file.txt C:\newlocation`. del: deletes files. `del /f /q file.txt` (/f=force, /q=quiet). ren or rename: renames files. `ren oldname.txt newname.txt`. type: displays file contents (like cat in Linux). `type file.txt`. attrib: view or set file attributes. `attrib +h file.txt` (hidden), `attrib +r` (read-only), `attrib +s` (system), `attrib -h` (remove hidden).
Disk and File System Commands
chkdsk: Check Disk — scans and repairs file system errors. `chkdsk C: /f` (fix errors — must schedule for C: when in use). `chkdsk C: /r` (locate bad sectors and recover readable info — implies /f). diskpart: disk partitioning utility. Interactive: type `diskpart`, then `list disk`, `select disk 0`, `list partition`, `select partition 1`, `format fs=ntfs quick`, `assign letter=E`. format: formats volumes. `format E: /fs:ntfs /q` (quick format). sfc (System File Checker): scans and repairs protected Windows system files. `sfc /scannow` (requires admin). DISM (Deployment Image Servicing and Management): repairs Windows image. `DISM /Online /Cleanup-Image /RestoreHealth`. Run DISM before SFC if SFC fails.
Network Commands
ipconfig: displays IP configuration. `ipconfig` (basic), `ipconfig /all` (detailed, including MAC address, DHCP server, DNS servers). `ipconfig /release` (release DHCP lease), `ipconfig /renew` (get new IP from DHCP), `ipconfig /flushdns` (clear DNS resolver cache). ping: tests connectivity. `ping 8.8.8.8`, `ping -t google.com` (continuous). tracert: traces the route packets take. `tracert google.com`. nslookup: DNS query tool. `nslookup google.com`, `nslookup google.com 8.8.8.8` (query specific DNS server). netstat: shows active connections. `netstat -a` (all), `netstat -n` (numeric), `netstat -b` (show process for each connection — requires admin). net: manages network resources. `net use`, `net share`, `net user`, `net localgroup`. pathping: combines ping and tracert, shows packet loss per hop.
Process and System Commands
tasklist: lists running processes. `tasklist`, `tasklist /fi "imagename eq notepad.exe"` (filter). taskkill: terminates processes. `taskkill /im notepad.exe /f` (force kill by name), `taskkill /pid 1234 /f` (by PID). shutdown: shuts down or restarts. `shutdown /s /t 0` (immediate shutdown), `shutdown /r /t 0` (restart), `shutdown /a` (abort scheduled shutdown), `shutdown /l` (logoff). sc: Service Control — manages Windows services. `sc query`, `sc start servicename`, `sc stop servicename`, `sc config servicename start=auto`. systeminfo: displays system configuration summary (OS version, RAM, patches, boot time). hostname: displays the computer name. ver: displays Windows version. msconfig (System Configuration): run from CMD, manages startup items and boot options. gpupdate /force: applies Group Policy updates.
PowerShell Essentials
PowerShell is the modern replacement for CMD, using object-based cmdlets. Run as admin via: right-click PowerShell → Run as Administrator. Common cmdlets: Get-Command (list all commands), Get-Help <cmdlet> (help), Set-ExecutionPolicy RemoteSigned (allows local scripts to run). File system: Get-ChildItem (like dir), Copy-Item, Move-Item, Remove-Item, New-Item. Process management: Get-Process, Stop-Process -Name notepad. Service management: Get-Service, Start-Service, Stop-Service, Set-Service. Network: Test-NetConnection (like ping with more info), Get-NetIPConfiguration (like ipconfig). PowerShell scripts use .ps1 extension. Execution policy controls whether scripts run: Restricted (default, no scripts), RemoteSigned (local scripts OK, remote must be signed), Unrestricted (all scripts run with warning).
Recovery and Boot Commands
bootrec: repairs Windows boot records. Run from Windows Recovery Environment (WinRE): `bootrec /fixmbr` (repair MBR), `bootrec /fixboot` (repair boot sector), `bootrec /rebuildbcd` (rebuild Boot Configuration Data — use when Windows doesn't appear in boot menu). bcdedit: Boot Configuration Data editor. View boot entries: `bcdedit /enum`. Add safe mode entry: complex, usually done via System Configuration. regedit: Registry Editor — opens the Windows registry GUI. Run from CMD: `regedit`. reg: command-line registry tool. `reg query HKLM\Software\Microsoft\Windows\CurrentVersion`. winver: displays Windows version in a GUI dialog. mstsc: launches Remote Desktop Connection client.