comptia-a-plus-core2/notes/OS-4-windows-command-line.md

6.2 KiB

OS-4: Windows Command Line

Status: not started

Domain:

  • 1.0 Operating Systems

Objective alignment:

  • 1.5 Windows command-line tools
  • 1.7 Windows networking basics
  • 3.1 Windows troubleshooting support

What You Need To Know

Core 2 command questions usually ask, "Which command would you use?"

Think in buckets:

  • Navigation: move around files and folders.
  • Network: check IP address, connectivity, DNS, routes, and connections.
  • Disk/file repair: check file systems and system files.
  • Identity/system info: computer name, signed-in user, Windows version.
  • Group Policy: update or report applied policies.
  • Help: find command syntax.

Some commands are safe to run anytime. Others can change disks or files, so use them carefully.

Memory Tricks

  • ipconfig = IP configuration.
  • ping = "Are you alive?"
  • tracert = trace route.
  • nslookup = name server lookup.
  • netstat = network statistics.
  • chkdsk = check disk.
  • sfc = system file checker.
  • gpupdate = Group Policy update.
  • gpresult = Group Policy result.
  • /? = "How do I use this?"

Commands To Enter

Enter these on Windows PowerShell or Command Prompt.

Navigation

dir

What it does:

  • Lists files and folders in the current directory.
  • Similar Linux command: ls.
cd

What it does:

  • Shows or changes the current directory.
  • cd .. moves up one folder.
mkdir test-folder

What it does:

  • Creates a folder named test-folder.
  • md does the same thing.
rmdir test-folder

What it does:

  • Removes an empty folder.
  • rd does the same thing.

Network

ipconfig

What it does:

  • Shows IP address, subnet mask, and default gateway for network adapters.
ipconfig /all

What it does:

  • Shows detailed adapter info, including MAC address, DNS servers, DHCP status, and lease details.
ping 127.0.0.1

What it does:

  • Tests the local TCP/IP stack using the loopback address.
  • If this fails, the local networking stack has a problem.
ping 8.8.8.8

What it does:

  • Tests basic IP connectivity to an external address.
  • If this works but names do not, suspect DNS.
nslookup example.com

What it does:

  • Queries DNS for a hostname.
  • Useful when websites fail by name but IP connectivity works.
tracert example.com

What it does:

  • Shows the router hops toward a destination.
  • Useful for finding where a path may stop.
pathping example.com

What it does:

  • Combines route tracing with packet-loss statistics.
  • Takes longer than tracert.
netstat -ano

What it does:

  • Shows active connections and listening ports.
  • -a shows all connections/listeners.
  • -n keeps addresses numeric.
  • -o shows process IDs.

Disk and File Repair

chkdsk

What it does:

  • Checks the disk file system status.
chkdsk /f

What it does:

  • Fixes logical file system errors.
  • May need to run at startup if the drive is locked.
chkdsk /r

What it does:

  • Looks for bad sectors and recovers readable information.
  • Includes /f.
  • Can take a long time.
sfc /scannow

What it does:

  • Scans protected Windows system files and repairs them when possible.

Identity and System Info

hostname

What it does:

  • Shows the computer name.
whoami

What it does:

  • Shows the current user.
whoami /all

What it does:

  • Shows current user, groups, privileges, and security identifier details.
winver

What it does:

  • Opens the Windows version/build dialog.

Group Policy

gpupdate /force

What it does:

  • Forces a Group Policy refresh.
  • Most relevant on domain-joined business systems.
gpresult /r

What it does:

  • Shows Resultant Set of Policy summary for the user/computer.
  • Use it to verify what policies applied.

Help

ipconfig /?

What it does:

  • Shows help and syntax for ipconfig.
  • Most Windows commands support /?.
help dir

What it does:

  • Shows help for the dir command.

Commands To Know But Treat Carefully

format

What it does:

  • Formats a volume.
  • Warning: this can erase data.
diskpart

What it does:

  • Opens a powerful disk partitioning tool.
  • Warning: incorrect commands can erase partitions or make a system unbootable.
robocopy

What it does:

  • Copies files and folders robustly.
  • Useful for backups and migrations.
  • Be careful with mirror options because they can delete destination files.

Linux Comparison Commands

ls
pwd
cd
mkdir test-folder
rmdir test-folder
ip addr
ping 127.0.0.1
traceroute example.com
dig example.com
df -h
du -h
ps aux
top

Why this matters:

  • Linux command practice helps you understand the same troubleshooting ideas across operating systems.
  • Exact commands differ, but the goal is often the same: identify the system, check network state, inspect storage, and view running processes.

Mini Lab

Goal:

  • Practice safe command-line troubleshooting.

Windows:

  1. Run hostname.
  2. Run whoami.
  3. Run winver.
  4. Run ipconfig.
  5. Run ipconfig /all.
  6. Run ping 127.0.0.1.
  7. Run nslookup example.com.
  8. Run netstat -ano.
  9. Run sfc /scannow.
  10. Run ipconfig /?.

Record:

  • Computer name:
  • Current user:
  • IPv4 address:
  • Default gateway:
  • DNS server:
  • Did loopback ping work?
  • Did DNS lookup work?
  • One listening port from netstat -ano:

Linux:

  1. Run hostname.
  2. Run whoami.
  3. Run ip addr.
  4. Run ping -c 4 127.0.0.1.
  5. Run df -h.
  6. Run ps aux.
  7. Run top, then press q.

Record:

  • Hostname:
  • Current user:
  • IP address:
  • Root filesystem free space:
  • One running process:

Quick Check Before Quiz

You are ready for the OS-4 quiz when you can answer these without looking:

  • Which command shows full Windows IP configuration?
  • Which command tests DNS name resolution?
  • Which command shows active connections and process IDs?
  • Which command repairs protected Windows system files?
  • Which command forces Group Policy refresh?
  • Which commands can erase data if misused?