Windows Commands
Windows provides two major command-line environments:
Windows ├── Command Prompt (CMD) │ └── cmd.exe │ └── PowerShell └── powershell.exe / pwsh.exe
These commands allow you to manage:
- files and folders
- processes
- users
- networking
- disks
- services
- system configuration
- troubleshooting
1. Command Prompt vs PowerShell
| Feature | CMD | PowerShell |
|---|---|---|
| Executable | cmd.exe | powershell.exe / pwsh.exe |
| Older environment | Yes | No |
| Scripting | Batch .bat/.cmd | PowerShell scripts .ps1 |
| Output | Mainly text | Objects |
| Modern administration | Limited compared with PowerShell | Very powerful |
| Linux-like aliases | Few | Many |
| Common use | Basic Windows commands | Administration/automation |
Example CMD:
dir
PowerShell:
Get-ChildItem
2. Basic Command Syntax
Generally:
command [options] [arguments]
Example:
dir /a
Here:
dir → command /a → option
PowerShell commonly uses:
Get-Process -Name chrome
3. Getting Help
CMD
help
Specific command:
help dir
You can also use:
dir /?
PowerShell
Get-Help Get-Process
Example:
Get-Help Get-Service
Detailed:
Get-Help Get-Service -Detailed
4. Current Directory
CMD
cd
or:
echo %cd%
PowerShell
Get-Location
Alias:
pwd
5. List Files
CMD — dir
dir
Example:
C:\Users\Uday>dir Documents Downloads Pictures test.txt
Show hidden/system files:
dir /a
PowerShell
Get-ChildItem
Aliases:
ls dir
So in PowerShell:
ls
works, but its underlying command is Get-ChildItem.
6. Change Directory
CMD:
cd Documents
PowerShell:
Set-Location Documents
PowerShell alias:
cd Documents
Parent directory
cd ..
Root of current drive
cd \
Change drive
CMD:
D:
PowerShell:
Set-Location D:\
7. Create Directory
CMD:
mkdir test
or:
md test
PowerShell:
New-Item -ItemType Directory test
8. Create a File
CMD:
type nul > file.txt
PowerShell:
New-Item file.txt -ItemType File
Another PowerShell method:
"" | Out-File file.txt
9. Display File Contents
CMD — type
type file.txt
PowerShell
Get-Content file.txt
Alias:
cat file.txt
PowerShell's cat is an alias for Get-Content.
10. Copy Files
CMD:
copy file.txt backup.txt
Copy to directory:
copy file.txt C:\Backup\
PowerShell
Copy-Item file.txt backup.txt
Directory:
Copy-Item project C:\Backup\ -Recurse
11. Move Files
CMD:
move file.txt Documents\
Rename:
move old.txt new.txt
PowerShell:
Move-Item file.txt Documents\
Rename:
Rename-Item old.txt new.txt
12. Delete Files
CMD:
del file.txt
or:
erase file.txt
PowerShell:
Remove-Item file.txt
Delete a directory and its contents:
Remove-Item project -Recurse
⚠️ Be careful with recursive deletion.
13. Remove Directory
CMD:
rmdir test
or:
rd test
For a directory containing files:
rmdir /s test
PowerShell:
Remove-Item test -Recurse
14. Rename
CMD:
ren old.txt new.txt
PowerShell:
Rename-Item old.txt new.txt
15. Clear Screen
CMD:
cls
PowerShell:
Clear-Host
Alias:
cls
16. Echo
CMD:
echo Hello Windows
PowerShell:
Write-Output "Hello Windows"
or:
echo "Hello Windows"
17. Environment Variables
CMD
Display:
echo %PATH%
Set temporarily:
set NAME=Uday
Display:
echo %NAME%
PowerShell
$env:PATH
Set:
$env:NAME="Uday"
Display:
$env:NAME
18. PATH
The PATH environment variable tells the shell where to look for executable programs.
CMD:
echo %PATH%
PowerShell:
$env:PATH
Conceptually:
Command ↓ PATH ↓ Search directories ↓ Executable
19. Find Executable
CMD:
where python
Example:
C:\Users\Uday\AppData\Local\Programs\Python\Python314\python.exe
PowerShell:
Get-Command python
This is very useful when troubleshooting PATH problems.
20. System Information
systeminfo
Displays detailed Windows system information.
systeminfo
Information can include:
- OS version
- system manufacturer
- system model
- RAM
- boot time
- Windows installation information
- network configuration
21. Windows Version
CMD:
ver
PowerShell:
$PSVersionTable
For Windows OS details:
Get-ComputerInfo
22. Hostname
CMD:
hostname
PowerShell:
$env:COMPUTERNAME
23. User Information
CMD:
whoami
Example:
desktop\uday
More information:
whoami /all
PowerShell
whoami
or:
$env:USERNAME
24. Logged-in Users
CMD:
query user
Another:
quser
Depending on Windows edition/configuration, availability can vary.
25. Processes
tasklist
Shows running processes.
tasklist
Example:
Image Name PID ==================== chrome.exe 4520 explorer.exe 2816 notepad.exe 5120
26. Find a Specific Process
tasklist | findstr chrome
This uses a pipe:
tasklist ↓ findstr ↓ chrome
27. PowerShell Process Commands
List processes:
Get-Process
Find Chrome:
Get-Process chrome
Find by name:
Get-Process | Where-Object {$_.ProcessName -like "*chrome*"}
28. Terminate a Process
CMD:
taskkill /PID 4520
Force:
taskkill /PID 4520 /F
By image name:
taskkill /IM notepad.exe
Force by name:
taskkill /IM notepad.exe /F
⚠️ Forcefully terminating a process can cause loss of unsaved data.
29. PowerShell Process Termination
Stop-Process -Name notepad
By PID:
Stop-Process -Id 4520
Force:
Stop-Process -Id 4520 -Force
30. CPU and Memory
PowerShell:
Get-Process
You can inspect properties such as:
Get-Process | Select-Object Name,Id,CPU,WorkingSet
Windows also provides:
Task Manager
for interactive CPU/RAM monitoring.
31. Networking — ipconfig
Display network configuration:
ipconfig
Detailed information:
ipconfig /all
Important information includes:
- IPv4 address
- IPv6 address
- subnet mask
- default gateway
- DNS servers
- MAC address
32. Renew DHCP Address
Release:
ipconfig /release
Renew:
ipconfig /renew
Useful when troubleshooting DHCP/network configuration.
33. DNS Cache
Display DNS cache:
ipconfig /displaydns
Clear DNS cache:
ipconfig /flushdns
34. ping
Tests network reachability.
ping google.com
Or:
ping 8.8.8.8
Example:
Reply from 8.8.8.8: bytes=32 time=20ms TTL=...
35. tracert
Shows the route toward a destination.
tracert google.com
Conceptually:
Your PC ↓ Router ↓ ISP ↓ Intermediate routers ↓ Destination
36. pathping
Combines features related to path tracing and packet-loss/latency analysis.
pathping google.com
It can take some time because it collects measurements.
37. DNS — nslookup
nslookup google.com
Can be used to query DNS information.
Example:
nslookup example.com
38. Network Connections — netstat
netstat
Show listening connections/ports:
netstat -ano
Important fields can include:
Proto Local Address Foreign Address State PID
For example:
TCP 0.0.0.0:80 ... LISTENING 1234
39. Modern PowerShell Networking
Get network adapters:
Get-NetAdapter
Get IP addresses:
Get-NetIPAddress
Get routes:
Get-NetRoute
Test connectivity:
Test-Connection google.com
Test a TCP port:
Test-NetConnection example.com -Port 443
40. Windows Firewall
CMD can use:
netsh advfirewall
For example, view firewall state:
netsh advfirewall show allprofiles
PowerShell:
Get-NetFirewallProfile
41. Services
CMD — sc
Query a service:
sc query
Specific service:
sc query w32time
Start:
sc start w32time
Stop:
sc stop w32time
42. PowerShell Services
List:
Get-Service
Specific service:
Get-Service w32time
Start:
Start-Service w32time
Stop:
Stop-Service w32time
Restart:
Restart-Service w32time
43. Service Manager
GUI:
services.msc
Run:
Win + R ↓ services.msc
44. Disk Management Commands
diskpart
Windows command-line disk-management utility.
Start:
diskpart
Then:
DISKPART>
List disks:
list disk
List partitions:
list partition
List volumes:
list volume
⚠️ diskpart can modify partitions and disks. Commands such as clean, delete, format, and partition operations can destroy data. Always verify the selected disk/volume.
45. chkdsk
Checks filesystem/disk-related issues.
Basic:
chkdsk C:
A commonly used repair form is:
chkdsk C: /f
Some operations may require administrator privileges and/or a reboot if the volume is in use.
46. sfc
System File Checker checks protected Windows system files.
sfc /scannow
Typically run from an elevated Command Prompt.
47. DISM
Deployment Image Servicing and Management
Useful for repairing Windows component-store/system-image problems.
Example:
DISM /Online /Cleanup-Image /RestoreHealth
This is commonly used alongside:
sfc /scannow
A common troubleshooting sequence is:
DISM /Online /Cleanup-Image /RestoreHealth sfc /scannow
48. Event Logs
Windows records system/application/security events.
PowerShell:
Get-WinEvent -LogName System
For example:
Get-WinEvent -LogName Application -MaxEvents 20
GUI:
eventvwr.msc
49. shutdown
Shutdown:
shutdown /s /t 0
Restart:
shutdown /r /t 0
Abort a scheduled shutdown:
shutdown /a
50. taskmgr
Open Task Manager:
taskmgr
Or:
Ctrl + Shift + Esc
51. devmgmt.msc
Open Device Manager:
devmgmt.msc
Useful for:
- hardware detection
- driver status
- driver troubleshooting
52. msinfo32
Open System Information:
msinfo32
Provides detailed hardware/software information.
53. dxdiag
DirectX Diagnostic Tool:
dxdiag
Useful for information about:
- graphics
- audio
- DirectX
- drivers
- system configuration
54. msconfig
System Configuration:
msconfig
It provides configuration options related to:
- boot
- services
- startup/configuration troubleshooting
Be careful when changing boot or service settings.
55. File Search
CMD:
dir /s filename.txt
PowerShell:
Get-ChildItem -Path C:\ -Filter file.txt -Recurse
PowerShell:
Get-ChildItem -Recurse -Filter *.py
56. findstr
Windows CMD text-search utility.
findstr "error" log.txt
Search recursively:
findstr /S /I "password" *.txt
Where:
/S → subdirectories /I → case-insensitive
57. Compare Files
CMD:
fc file1.txt file2.txt
PowerShell can use:
Compare-Object (Get-Content file1.txt) (Get-Content file2.txt)
58. Archives in PowerShell
PowerShell can work with ZIP archives.
Compress:
Compress-Archive -Path project\* -DestinationPath project.zip
Extract:
Expand-Archive project.zip -DestinationPath project
59. tar on Modern Windows
Modern Windows installations may also provide:
tar
Create:
tar -cf backup.tar project
Extract:
tar -xf backup.tar
60. curl and wget
Modern Windows commonly includes curl.
curl https://example.com
PowerShell also provides web-related cmdlets such as:
Invoke-WebRequest https://example.com
Alias:
wget https://example.com
However, in PowerShell, wget can be an alias rather than the GNU/Linux wget program.
61. net Command
The net command provides several administrative functions.
Examples:
net user
List users.
net user Uday
Show information about a user.
List shares:
net share
View network-related configuration:
net use
Manage services:
net start
62. User Management
Create a local user from an elevated CMD:
net user username password /add
Example:
net user testuser *
Using * prompts for the password instead of displaying it in the command line.
⚠️ User-management commands change system accounts. Use them only on systems you administer.
63. Local Groups
List groups:
net localgroup
Display a group:
net localgroup administrators
Add a user to a local group:
net localgroup administrators username /add
⚠️ This grants administrative privileges, so it should only be done intentionally on systems you control.
64. File Permissions — icacls
Windows ACL permissions can be viewed with:
icacls file.txt
Example:
icacls C:\Users\Uday\Documents\file.txt
This shows access control entries associated with the file.
65. Symbolic Links
Windows supports symbolic links.
Example:
mklink link.txt original.txt
Directory symbolic link:
mklink /D linkfolder originalfolder
Depending on Windows configuration, creating symbolic links may require appropriate privileges or Developer Mode.
66. Windows Command Redirection
Like Linux, Windows supports redirection.
Output
command > output.txt
Append
command >> output.txt
Input
command < input.txt
Error
command 2> error.txt
67. Windows Pipe
The pipe symbol is:
|
Example:
tasklist | findstr chrome
Flow:
tasklist ↓ | ↓ findstr ↓ Filtered result
68. Command Chaining
&
Run commands sequentially:
command1 & command2
&&
Run second command if first succeeds:
command1 && command2
||
Run second command if first fails:
command1 || command2
Example:
mkdir test && cd test
69. PowerShell Pipeline
PowerShell's pipeline is especially powerful because it normally passes objects, not merely formatted text.
Example:
Get-Process | Where-Object {$_.CPU -gt 100}
Conceptually:
Get-Process ↓ Process Objects ↓ Where-Object ↓ Filtered Objects
Another:
Get-Service | Where-Object {$_.Status -eq "Running"}
70. Important PowerShell Commands
| Purpose | PowerShell |
|---|---|
| Current directory | Get-Location |
| List files | Get-ChildItem |
| Change directory | Set-Location |
| Create | New-Item |
| Copy | Copy-Item |
| Move | Move-Item |
| Rename | Rename-Item |
| Delete | Remove-Item |
| Read file | Get-Content |
| Processes | Get-Process |
| Services | Get-Service |
| Network adapter | Get-NetAdapter |
| IP address | Get-NetIPAddress |
| Route | Get-NetRoute |
| Event logs | Get-WinEvent |
| Help | Get-Help |
71. CMD vs PowerShell Command Table
| Task | CMD | PowerShell |
|---|---|---|
| List files | dir | Get-ChildItem |
| Current directory | cd | Get-Location |
| Change directory | cd | Set-Location |
| Create directory | mkdir | New-Item -ItemType Directory |
| Create file | type nul > file | New-Item file |
| Read file | type | Get-Content |
| Copy | copy | Copy-Item |
| Move | move | Move-Item |
| Rename | ren | Rename-Item |
| Delete | del | Remove-Item |
| Processes | tasklist | Get-Process |
| Kill process | taskkill | Stop-Process |
| Services | sc | Get-Service |
| Network config | ipconfig | Get-NetIPConfiguration / Get-NetIPAddress |
| Network test | ping | Test-Connection |
| DNS | nslookup | Resolve-DnsName |
| Help | help | Get-Help |
72. Important Windows Commands for Exams
File management
dir cd mkdir rmdir copy move del ren type
Process management
tasklist taskkill
Networking
ipconfig ping tracert pathping nslookup netstat
System
systeminfo hostname whoami ver
Troubleshooting
chkdsk sfc DISM eventvwr.msc
Hardware
devmgmt.msc msinfo32 dxdiag
Services
sc net start net stop Get-Service
Administration
diskpart net user net localgroup icacls
73. Practical Example
Suppose you want to create a project from CMD:
mkdir MyProject cd MyProject mkdir src mkdir docs type nul > README.txt dir
Result conceptually:
MyProject │ ├── src ├── docs └── README.txt
Then:
echo Hello Windows > README.txt type README.txt
Output:
Hello Windows
74. Practical Network Troubleshooting
Suppose internet is not working.
Step 1 — Check IP configuration
ipconfig /all
Step 2 — Test local network stack
ping 127.0.0.1
Step 3 — Test gateway
ping <default-gateway>
Step 4 — Test internet by IP
ping 8.8.8.8
Step 5 — Test DNS
nslookup example.com
Step 6 — Test destination by hostname
ping example.com
Step 7 — Inspect route
tracert example.com
This helps distinguish:
Local PC problem ↓ Gateway problem ↓ Internet routing problem ↓ DNS problem
75. Practical Process Troubleshooting
Suppose a program freezes.
Find the process:
tasklist | findstr program
Find its PID:
program.exe 4520
Then terminate if necessary:
taskkill /PID 4520
Force only if needed:
taskkill /PID 4520 /F
PowerShell alternative:
Get-Process program Stop-Process -Name program
76. Windows Command Memory Map
WINDOWS COMMANDS │ ┌─────────────────┼─────────────────┐ ↓ ↓ ↓ FILES PROCESS NETWORK dir tasklist ipconfig cd taskkill ping copy Get-Process tracert move nslookup del netstat │ │ │ ├─────────────────┼─────────────────┤ ↓ ↓ ↓ SYSTEM DISK SERVICE systeminfo diskpart sc hostname chkdsk net start whoami fsutil* net stop │ ├─────────────────────────────┐ ↓ ↓ TROUBLESHOOTING SECURITY sfc icacls DISM net user eventvwr net localgroup
fsutil is an advanced Windows filesystem utility and should be used carefully.
🧠 Final Exam Revision
CMD
Command Prompt (
cmd.exe) is the traditional Windows command-line interpreter used to execute commands and batch scripts.
PowerShell
PowerShell is a command-line shell and scripting environment designed for Windows administration and automation, with object-based pipeline processing.
Most important commands
dir → list files cd → change directory mkdir → create directory copy → copy move → move del → delete ren → rename type → display file tasklist → list processes taskkill → terminate process ipconfig → network configuration ping → connectivity test tracert → route tracing nslookup → DNS lookup netstat → network connections systeminfo → system information whoami → current user hostname → computer name chkdsk → disk/filesystem checking sfc → system-file checking DISM → Windows image/component repair diskpart → disk/partition management sc → service control icacls → file/folder ACLs
Memory trick
DIR → FILE → PROCESS → NETWORK → SYSTEM → DISK → SERVICE → SECURITY