Why Use the Command Line?
The Windows Command Prompt (CMD) offers several advantages over the graphical interface:
- Lower resource usage — CLIs require fewer system resources than graphics-intensive GUIs. This is particularly valuable for older hardware, systems with limited memory, or cloud environments where lower resources mean lower costs.
- Automation — Creating a batch file or script with the commands you need to repeat is far easier than automating GUI interactions.
- Remote management — CLI makes it very convenient to use protocols like SSH to manage a remote system such as a server, router, or IoT device. This works well on slow network speeds and systems with limited resources.
Environment and System Info
Commands can only be issued within the Windows Path. To check your current path:
set
Example output:
ALLUSERSPROFILE=C:\ProgramData
APPDATA=C:\Users\user\AppData\Roaming
CommonProgramFiles=C:\Program Files\Common Files
OS Version
ver
System Information
systeminfo
Example output:
Host Name: WINSRV2022-CORE
OS Name: Microsoft Windows Server 2022 Datacenter
OS Version: 10.0.20348 N/A Build 20348
OS Manufacturer: Microsoft Corporation
OS Configuration: Standalone Server
Help and Pagination
help— Provides help information for a specific command.cls— Clears the Command Prompt screen.
For long output, pipe it through more to view page by page:
driverquery | more
Press the spacebar to page through. Exit with Ctrl + C.
Use /? with most commands to display help:
netstat /?
Network Commands
Check Network Configuration
ipconfig
ipconfig /all
Test Connectivity
ping google.com
Sends ICMP packets and waits for a response. If a response is received, you can reach the target and the target can reach you.
Trace Network Route
tracert google.com
Traces the network route to reach the target by monitoring routers along the path.
DNS Lookup
nslookup example.com
Looks up a host or domain and returns its IP address using the default name server.
Specify a DNS record type:
nslookup --type=MX example.com
View Active Connections
netstat
Displays current network connections and listening ports. Flags:
| Flag | Description |
|---|---|
-a | Displays all established connections and listening ports |
-b | Shows the program associated with each port/connection |
-o | Reveals the process ID (PID) associated with the connection |
-n | Uses numerical form for addresses and port numbers |
Combined:
netstat -abon
File and Disk Management
Current Directory
cd
Displays the current drive and directory (equivalent to pwd in Linux).
List Directory Contents
dir
dir /a
Includes hidden and system files.
dir /s
Displays files in the current directory and all subdirectories.
Visualize Directory Tree
tree
Create and Remove Directories
mkdir foldername
rmdir foldername
File Operations
| Command | Description |
|---|---|
type | View content of a text file |
copy | Copy a file |
move | Move a file |
del | Remove files |
erase | Remove files (alias for del) |
Task and Process Management
List Running Processes
tasklist
Filter by process name:
tasklist /FI "imagename eq sshd.exe"
/FI sets a filter — in this case, image name equals sshd.exe.
Terminate a Process
taskkill /PID 4567
Other Useful Commands
| Command | Description |
|---|---|
chkdsk | Checks the file system and disk volumes for errors and bad sectors. |
driverquery | Displays a list of installed device drivers. |
sfc /scannow | Scans system files for corruption and repairs them if possible. |
shutdown /s | Shuts down the system. |
shutdown /r | Reboots the system. |
shutdown /a | Cancels a pending shutdown or reboot. |
Using `more`
Display a text file page by page:
more file.txt
Pipe long command output:
driverquery | more
Quick Reference Summary
Network:
ipconfig - Network config
ipconfig /all - Full network config
ping - Test connectivity
tracert - Trace route
nslookup - DNS lookup
netstat -abon - Active connections + PIDs
Files:
cd - Current dir (like pwd)
dir - List dir (like ls)
mkdir / rmdir - Create/remove directory
type - View file content
copy / move - Copy/move files
del / erase - Delete files
Processes:
tasklist - List running processes
taskkill /PID - Terminate process by PID
System:
ver - OS version
systeminfo - Full system info
set - Environment variables
chkdsk - Disk check
sfc /scannow - System file check
Summary
The Windows Command Prompt provides a powerful, low-overhead interface for system administration, automation, and remote management. Mastering commands across networking (ipconfig, netstat, ping, tracert), file management (dir, copy, move, del), and process control (tasklist, taskkill) forms the foundation of effective Windows administration from the command line.