Objective 1.5: Given a scenario, use the appropriate Microsoft command-line tools
Cert: CompTIA A+ Core 2 (220-1202) V15 Domain: 1.0 Operating Systems Weight: Part of the 28% Operating Systems domain Depth: Given a scenario, use. The candidate must pick the right Windows command for a given diagnostic or admin task.
What this objective tests
You should know what each common Windows command does, what its key flags are, and when to reach for it over a GUI tool. CompTIA tests these as direct fact recall and as scenario-driven "which command does X" questions.
Most of these run in Command Prompt (cmd.exe) or PowerShell. Some need elevated (Administrator) privileges.
Key facts
cd (change directory):
- Navigate the filesystem in the current shell.
cd \jumps to the drive root.cd ..goes up one folder.cd C:\Users\Namejumps to an absolute path.cd /d D:\folderchanges drive AND directory in one step.
dir (directory listing):
- List files and folders in the current directory.
- Common flags:
/ashows hidden files,/srecurses into subfolders,/osorts,/ppauses per page,/bbare format (just names).
ipconfig:
- Show IP configuration for all adapters.
ipconfig /allshows MAC addresses, DHCP servers, DNS servers, lease times.ipconfig /releasereleases the current DHCP lease.ipconfig /renewrequests a fresh one.ipconfig /flushdnsclears the DNS resolver cache (use when DNS records changed and you're still getting old answers).
ping:
- Test ICMP reachability to a host by name or IP.
ping example.comsends 4 echo requests by default.ping -t example.compings continuously until Ctrl+C.- The DNS vs connectivity discriminator:
ping hostnameworks ANDping IPworks = both fine.ping IPworks butping hostnamefails = DNS issue. Neither works = network issue.
netstat:
- Show active TCP/UDP connections and listening ports.
netstat -anoshows all connections + listening + with PID. Useful for "what process is using port X."netstat -rnshows the routing table.
nslookup:
- Query DNS records directly. Tells you which DNS server answered and what record(s) it returned.
nslookup example.comreturns A/AAAA records.nslookup -type=MX example.comreturns mail records.- First tool after ping when you suspect DNS is broken.
net use:
- Map a network drive or connect to a shared resource.
net use Z: \\server\sharemaps Z: to the share.net use Z: /deleteunmaps it.net usewith no args lists current mappings.
tracert (traceroute):
- Show the network path to a destination, hop by hop, with latency per hop.
- Use when you can reach a destination but it's slow, or when you can't reach it and need to find where the path breaks.
pathping:
- Combines tracert and ping. Sends multiple packets to each hop and reports loss/latency stats over time.
- Slower than tracert (takes a few minutes) but better data for diagnosing intermittent path issues.
chkdsk:
- Check Disk. Scan a drive for filesystem errors and bad sectors.
chkdsk C: /ffixes errors (requires reboot for the system drive).chkdsk C: /radds bad sector recovery (long run, hours on a large drive).- Use when filesystem appears corrupt or the OS reports disk errors.
format:
- Format a drive with a filesystem.
format D: /fs:ntfsformats D: as NTFS./qis quick format (just rewrites the filesystem header, doesn't check sectors).- Destructive. The data is gone.
diskpart:
- Interactive partition management. Create, delete, format, assign letters, set active partitions.
- More powerful and more dangerous than Disk Management GUI. Wrong drive selection wipes the wrong disk.
- Standard tool for prepping drives during OS install or disk recovery.
md (mkdir):
- Create a directory.
md NewFolderormkdir NewFolder. md C:\Path\To\New\Foldercreates intermediate directories as needed.
rmdir (rd):
- Remove a directory.
rmdir EmptyFolderremoves an empty folder.rmdir /s FolderWithStuffremoves recursively (destructive). /qruns quietly without prompts.
robocopy:
- Robust file copy. Better than xcopy and the Explorer copy dialog for large or unreliable copies.
- Resumes interrupted copies, preserves attributes and permissions, throttles bandwidth, mirrors directories.
- Common flags:
/MIRmirrors source to destination (destructive on destination),/Ecopies all subdirectories including empty,/R:nretry count,/W:nwait between retries. - Standard tool for file server migrations and large user-data moves.
hostname:
- Print the current computer's hostname.
net user:
- Manage local user accounts from the command line.
net userlists local users.net user JohnDoe newpasswordresets JohnDoe's password (requires admin).net user JohnDoe /addcreates a new local user.
winver:
- Open the About Windows dialog. Shows Windows edition, version, build number.
- Quick way to know exactly what version you're on without digging through Settings.
whoami:
- Print the current user.
whoami /groupsshows group memberships.whoami /privshows privileges. - Useful in scripts and when troubleshooting permission issues.
[command name] /?:
- Universal help flag. Every Windows command supports
/?to show usage. - Memorize this: it's the single most-useful CompTIA-exam answer when you don't remember the exact flag.
gpupdate:
- Force a Group Policy refresh on the local machine.
gpupdate /forcereapplies all policies even if no changes are detected.- Use after editing Group Policy and you want changes immediately instead of waiting for the next refresh cycle (90 minutes default).
gpresult:
- Show what Group Policy settings are currently applied.
gpresult /rshows a summary.gpresult /h report.htmloutputs a detailed HTML report.- Use to diagnose "why isn't this policy taking effect on this PC."
sfc (System File Checker):
- Verify and repair Windows system files.
sfc /scannowscans all protected system files and repairs any that are corrupt (replaces from the local cache).- Run when you suspect system file corruption (BSODs, weird OS behavior).
- Often paired with DISM (
DISM /Online /Cleanup-Image /RestoreHealth) to repair the system file cache itself before running sfc.
Common gotchas
- Running ipconfig /release without /renew. PC drops its IP and doesn't get a new one until you
/renewor until Windows reaches back to DHCP on its own. - ping -t left running. Continuous ping racks up output and uses some bandwidth. Ctrl+C to stop.
- chkdsk /f on the system drive. Requires reboot because it needs exclusive access. Windows queues it for next boot. Plan for 15-60 minutes of downtime.
- format /q on a "failing" drive. Quick format doesn't check sectors. If you suspect bad sectors, use full format (no
/q). - diskpart wrong-disk wipe.
list diskthenselect disk Ncarefully. Wrong N = wrong drive deleted. - robocopy /MIR pointing the wrong way. Mirror mode deletes anything in the destination that's not in the source. Mirroring an empty folder onto a populated one wipes the populated one.
- gpupdate doesn't fix all settings. Some Group Policy changes (like installed software, security templates) require restart or logoff to take effect.
/forcedoesn't make those refresh either. - sfc reports "Windows Resource Protection could not perform the requested operation." Usually means the component store is corrupt. Run DISM RestoreHealth first, then sfc again.
Real-world context
Daily helpdesk command-line moves:
- "Internet seems down."
ipconfigto see if you have a valid IP.ping 8.8.8.8to test external connectivity.ping default-gatewayto test local.nslookup example.comto test DNS. - "Site is slow but not down."
pathping site.comto find the slow hop. - "Network drive disconnected."
net use Z: \\server\share /persistent:yesto re-map. - "Mass file move during a server migration."
robocopy \\old\share \\new\share /E /Z /COPYALL /R:3 /W:5 /LOG:robo.log. - "Suspect system file corruption." DISM RestoreHealth, then sfc /scannow.
- "Group Policy isn't applying." gpresult /h to see what's actually in effect. gpupdate /force to refresh.
Pro tip: most of these run faster as scripts than as ad-hoc typed commands. Save common workflows as .bat or .ps1 for reuse.
Sources
- [CompTIA A+ 220-1202 Exam Objectives Version 4.0, Section 1.5](../../../../../../30-RevyTechJourney/CompTIA%20A%2B%20220-1202%20Exam%20Objectives%20%284.0%29.pdf)
- [Microsoft Learn: Windows commands](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/windows-commands)
- [Microsoft Learn: robocopy](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/robocopy)
- [Microsoft Learn: chkdsk](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/chkdsk)
- [Microsoft Learn: sfc](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/sfc)
- [Microsoft Learn: diskpart](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/diskpart)
