Complete Command Line Reference: CMD, PowerShell & Bash Commands [2026]
The command line is the most powerful tool for system administrators, developers, and IT professionals. This comprehensive reference covers 500+ commands across CMD, PowerShell, and Bash, providing syntax, examples, and practical use cases for everyday tasks.
Whether you’re managing Windows servers, automating tasks with scripts, or working across platforms, this guide serves as your go-to reference for command line operations.
Table of Contents
- Introduction to Command Lines
- CMD vs PowerShell vs Bash
- Essential CMD Commands
- Essential PowerShell Cmdlets
- Bash Commands for Windows
- File Operations
- Directory Management
- Network Commands
- System Information
- User & Permission Management
- Active Directory Commands
- Process Management
- Quick Reference Tables
- Command Equivalents
- Frequently Asked Questions
Introduction to Command Lines
What is a Command Line Interface (CLI)?
A command line interface is a text-based interface for interacting with computer operating systems and software. Unlike graphical user interfaces (GUIs), CLIs allow users to execute commands by typing text commands.
Benefits of Command Line:
- Speed: Faster than clicking through multiple menus
- Automation: Scripts automate repetitive tasks
- Remote Management: Manage systems over SSH or PowerShell Remoting
- Resource Efficiency: Lower resource overhead than GUIs
- Precision: Exact control over system operations
- Batch Operations: Process hundreds of files with single command
Three Primary Command Line Environments
- CMD (Command Prompt): Legacy Windows command line
- PowerShell: Modern Windows automation framework
- Bash: Unix/Linux shell (available on Windows via WSL)
CMD vs PowerShell vs Bash
Feature Comparison
| Feature | CMD | PowerShell | Bash |
|---|---|---|---|
| Platform | Windows only | Windows, Linux, macOS | Unix/Linux/macOS, WSL |
| Release | 1981 | 2006 | 1989 |
| Scripting | Batch files (.bat) | Scripts (.ps1) | Shell scripts (.sh) |
| Object Model | Text-based | Object-based | Text-based |
| Aliases | Limited | Extensive | Extensive |
| Remote Management | Limited | Built-in (PS Remoting) | SSH |
| Package Manager | None | PowerShellGet | apt, yum, brew |
| Modern Features | ❌ Limited | ✅ Extensive | ✅ Extensive |
When to Use Each
Use CMD when:
- Running legacy batch scripts
- Quick file/directory operations
- Working with older Windows systems
- Simple tasks (navigating, copying files)
Use PowerShell when:
- Automating Windows administration
- Managing Active Directory
- Working with Azure, Microsoft 365
- Complex scripting with objects
- Remote system management
Use Bash when:
- Cross-platform scripting
- Linux/Unix server administration
- Development workflows (git, make, etc.)
- Container and DevOps operations
Essential CMD Commands
Navigation Commands
cd - Change Directory
Syntax:
cd [path]
Examples:
cd C:\Windows # Change to Windows directory
cd .. # Go to parent directory
cd \ # Go to root directory
cd "C:\Program Files" # Quotes for spaces
Related: How to Change Directory in CMD
dir - List Directory Contents
Syntax:
dir [path] [options]
Common Options:
/A: Show hidden files/S: Include subdirectories/B: Bare format (names only)/O:N: Order by name/O:D: Order by date
Examples:
dir # List current directory
dir /A # Include hidden files
dir /S *.txt # Find all .txt files recursively
dir /B > filelist.txt # Save file list to text file
Related: CMD List Files in Directory
tree - Display Directory Structure
Syntax:
tree [path] [options]
Examples:
tree # Show tree of current directory
tree /F # Include files
tree C:\Projets /A # ASCII characters (for redirection)
File Operations
copy - Copy Files
Syntax:
copy source destination [options]
Examples:
copy file.txt D:\Backup # Copy single file
copy *.txt D:\Documents # Copy all .txt files
copy file1.txt+file2.txt merged.txt # Concatenate files
Related: CMD Copy a File
xcopy - Advanced Copy
Syntax:
xcopy source destination [options]
Common Options:
/E: Copy subdirectories including empty ones/Y: Suppress overwrite confirmation/D: Copy only files newer than destination
Examples:
xcopy C:\Source D:\Backup /E /Y # Copy entire directory tree
xcopy C:\Data D:\Backup /D /E /Y # Incremental backup
move - Move/Rename Files
Syntax:
move source destination
Examples:
move file.txt D:\Documents # Move file
move oldname.txt newname.txt # Rename file
move *.log D:\Logs # Move all .log files
del - Delete Files
Syntax:
del [path] [options]
Common Options:
/P: Prompt for confirmation/F: Force delete read-only files/S: Delete from subdirectories/Q: Quiet mode (no confirmation)
Examples:
del file.txt # Delete single file
del *.tmp # Delete all .tmp files
del /S /Q *.bak # Delete all .bak files recursively
Related: CMD Delete All Files in a Directory
type - Display File Contents
Syntax:
type filename
Examples:
type file.txt # Display file contents
type file.txt | more # Display with pagination
Directory Operations
mkdir - Create Directory
Syntax:
mkdir directory_name
Examples:
mkdir NewFolder # Create directory
mkdir "New Folder" # Quotes for spaces
mkdir C:\Temp\Subfolder # Create with path
Related: CMD Create New Directory
rmdir - Remove Directory
Syntax:
rmdir [path] [options]
Common Options:
/S: Remove directory and all contents/Q: Quiet mode (no confirmation)
Examples:
rmdir EmptyFolder # Remove empty directory
rmdir /S /Q OldFolder # Remove directory and contents
Related: CMD Delete Directory
System Commands
systeminfo - Display System Information
Syntax:
systeminfo [/S computer] [/U user]
Examples:
systeminfo # Display local system info
systeminfo | findstr "System Type" # Filter specific information
tasklist - List Running Processes
Syntax:
tasklist [options]
Examples:
tasklist # List all processes
tasklist /FI "IMAGENAME eq notepad.exe" # Filter processes
tasklist /SVC # Show services in each process
taskkill - Terminate Processes
Syntax:
taskkill /IM imagename | /PID processid [options]
Common Options:
/F: Force termination/T: Terminate process tree
Examples:
taskkill /IM notepad.exe # Kill notepad
taskkill /PID 1234 /F # Force kill by process ID
taskkill /IM chrome.exe /F /T # Kill Chrome and child processes
Essential PowerShell Cmdlets
File System Cmdlets
Get-ChildItem - List Files and Directories
Syntax:
Get-ChildItem [[-Path] <String[]>] [parameters]
Aliases: gci, ls, dir
Examples:
Get-ChildItem # List current directory
Get-ChildItem -Recurse # List recursively
Get-ChildItem -Filter *.txt # Filter by extension
Get-ChildItem -Hidden # Show hidden files
Get-ChildItem | Where-Object {$_.Length -gt 1MB} # Files > 1MB
Related: Our comprehensive guides:
- PowerShell List Files in Directory
- PowerShell Get-ChildItem Filters
- Get-ChildItem Files Only
- Get-ChildItem Hidden Files
- Get-ChildItem Large Files
Copy-Item - Copy Files and Directories
Syntax:
Copy-Item [-Path] <String[]> [-Destination] <String> [parameters]
Examples:
Copy-Item file.txt D:\Backup # Copy file
Copy-Item C:\Source D:\Dest -Recurse # Copy directory tree
Copy-Item *.txt D:\Documents # Copy multiple files
Remove-Item - Delete Files and Directories
Syntax:
Remove-Item [-Path] <String[]> [parameters]
Examples:
Remove-Item file.txt # Delete file
Remove-Item C:\Temp\* -Recurse # Delete all contents
Remove-Item *.log -Force # Force delete
Related:
- PowerShell Delete All Files in Folder
- PowerShell Delete Files Older Than X Days
- PowerShell Delete Empty Folders
Get-Content - Read File Contents
Syntax:
Get-Content [-Path] <String[]> [parameters]
Aliases: gc, cat, type
Examples:
Get-Content file.txt # Read entire file
Get-Content file.txt -TotalCount 10 # First 10 lines
Get-Content file.txt -Tail 5 # Last 5 lines
Get-Content file.txt | Where-Object {$_ -match "error"} # Filter lines
Related:
Process Management Cmdlets
Get-Process - Retrieve Process Information
Syntax:
Get-Process [[-Name] <String[]>] [parameters]
Aliases: gps, ps
Examples:
Get-Process # List all processes
Get-Process -Name notepad # Specific process
Get-Process | Sort-Object CPU -Descending | Select-Object -First 10 # Top CPU users
Related: PowerShell Get-Process Guide
Stop-Process - Terminate Processes
Syntax:
Stop-Process [-Id] <Int32[]> | [-Name] <String[]> [parameters]
Examples:
Stop-Process -Name notepad # Stop by name
Stop-Process -Id 1234 # Stop by process ID
Get-Process chrome | Stop-Process # Pipeline usage
Service Management
Get-Service - Retrieve Service Information
Syntax:
Get-Service [[-Name] <String[]>] [parameters]
Aliases: gsv
Examples:
Get-Service # List all services
Get-Service -Name wuauserv # Specific service (Windows Update)
Get-Service | Where-Object {$_.Status -eq 'Running'} # Running services
Start-Service / Stop-Service
Examples:
Start-Service -Name wuauserv # Start service
Stop-Service -Name wuauserv # Stop service
Restart-Service -Name wuauserv # Restart service
Set-Service -Name wuauserv -StartupType Automatic # Set startup type
```powershell
---
## Bash Commands for Windows (WSL)
### File Operations
#### ls - List Directory Contents
**Syntax:**
```bash
ls [options] [path]
Common Options:
-l: Long format (permissions, owner, size, date)-a: Show hidden files (starting with .)-h: Human-readable sizes-R: Recursive-t: Sort by modification time
Examples:
ls # List current directory
ls -lah # Long format, all files, human-readable
ls -ltr # Long format, sorted by time (reverse)
find . -name "*.txt" # Find all .txt files
cp - Copy Files
Syntax:
cp [options] source destination
Common Options:
-r: Copy directories recursively-i: Interactive (prompt before overwrite)-v: Verbose-p: Preserve attributes
Examples:
cp file.txt /backup/ # Copy file
cp -r directory/ /backup/ # Copy directory
cp -v *.txt /documents/ # Copy with verbose output
mv - Move/Rename Files
Syntax:
mv [options] source destination
Examples:
mv file.txt /destination/ # Move file
mv oldname.txt newname.txt # Rename file
mv *.log /logs/ # Move multiple files
rm - Remove Files
Syntax:
rm [options] file
Common Options:
-r: Remove directories recursively-f: Force (no prompts)-i: Interactive (prompt for each file)
Examples:
rm file.txt # Delete file
rm -rf directory/ # Delete directory and contents (careful!)
rm *.tmp # Delete all .tmp files
Text Processing
grep - Search Text
Syntax:
grep [options] pattern [files]
Common Options:
-i: Case-insensitive-r: Recursive search-n: Show line numbers-v: Invert match (show non-matching lines)
Examples:
grep "error" logfile.txt # Search for "error"
grep -ri "password" /var/log/ # Recursive, case-insensitive
grep -n "TODO" *.py # Show line numbers
sed - Stream Editor
Syntax:
sed [options] 'command' file
Examples:
sed 's/old/new/' file.txt # Replace first occurrence per line
sed 's/old/new/g' file.txt # Replace all occurrences
sed -i 's/old/new/g' file.txt # Edit file in-place
awk - Text Processing
Syntax:
awk 'pattern {action}' file
Examples:
awk '{print $1}' file.txt # Print first column
awk -F':' '{print $1}' /etc/passwd # Use : as delimiter
awk '$3 > 100' data.txt # Filter rows where column 3 > 100
File Operations
Quick Reference Table
| Task | CMD | PowerShell | Bash |
|---|---|---|---|
| List files | dir | Get-ChildItem | ls -la |
| Copy file | copy file.txt dest\ | Copy-Item file.txt dest\ | cp file.txt dest/ |
| Move file | move file.txt dest\ | Move-Item file.txt dest\ | mv file.txt dest/ |
| Delete file | del file.txt | Remove-Item file.txt | rm file.txt |
| View file | type file.txt | Get-Content file.txt | cat file.txt |
| Find files | dir /S /B *.txt | Get-ChildItem -Recurse -Filter *.txt | find . -name "*.txt" |
| File size | dir file.txt | (Get-Item file.txt).Length | ls -lh file.txt |
Directory Management
Quick Reference Table
| Task | CMD | PowerShell | Bash |
|---|---|---|---|
| Current directory | cd | Get-Location | pwd |
| Change directory | cd path | Set-Location path | cd path |
| Create directory | mkdir folder | New-Item -ItemType Directory | mkdir folder |
| Remove directory | rmdir /S folder | Remove-Item -Recurse | rm -rf folder |
| List directories | dir /AD | Get-ChildItem -Directory | ls -d */ |
Network Commands
CMD Network Commands
ping - Test Network Connectivity
Syntax:
ping [-t] [-n count] target
Examples:
ping google.com # Ping 4 times (default)
ping -t google.com # Ping continuously
ping -n 10 192.168.1.1 # Ping 10 times
ipconfig - IP Configuration
Syntax:
ipconfig [/all] [/release] [/renew] [/flushdns]
Examples:
ipconfig # Basic IP info
ipconfig /all # Detailed info
ipconfig /flushdns # Clear DNS cache
ipconfig /release # Release DHCP lease
ipconfig /renew # Renew DHCP lease
netstat - Network Statistics
Syntax:
netstat [options]
Common Options:
-a: Show all connections-n: Show addresses numerically-o: Show process ID-b: Show executable name
Examples:
netstat -an # All connections, numeric
netstat -ano # Include process IDs
netstat -ano | findstr "LISTENING" # Show listening ports
nslookup - DNS Lookup
Syntax:
nslookup [host] [dns-server]
Examples:
nslookup google.com # DNS lookup
nslookup google.com 8.8.8.8 # Use specific DNS server
PowerShell Network Cmdlets
Test-Connection - Ping Alternative
Syntax:
Test-Connection [-ComputerName] <String[]> [parameters]
Examples:
Test-Connection google.com # Ping (4 times)
Test-Connection google.com -Count 10 # Ping 10 times
Test-Connection google.com -Quiet # Return boolean only
Get-NetIPAddress - IP Configuration
Syntax:
Get-NetIPAddress [parameters]
Examples:
Get-NetIPAddress # All IP addresses
Get-NetIPAddress -AddressFamily IPv4 # IPv4 only
Resolve-DnsName - DNS Resolution
Syntax:
Resolve-DnsName [-Name] <String> [parameters]
Examples:
Resolve-DnsName google.com # DNS lookup
Resolve-DnsName google.com -Type MX # MX records
Active Directory Commands
CMD AD Commands
net user - Manage Users
Syntax:
net user [username [password | *] [options]] [/DOMAIN]
Examples:
net user /DOMAIN # List all domain users
net user jdoe /DOMAIN # Get user info
net user jdoe NewPass123! /DOMAIN # Change password
net user jdoe /ACTIVE:NO /DOMAIN # Disable account
net group - Manage Groups
Syntax:
net group [groupname [/COMMENT:"text"]] [/DOMAIN]
Examples:
net group /DOMAIN # List all domain groups
net group "Domain Admins" /DOMAIN # List group members
net group "IT-Staff" jdoe /ADD /DOMAIN # Add user to group
dsquery - Query Active Directory
Syntax:
dsquery objecttype [parameters]
Examples:
dsquery user -name "John*" # Find users named John*
dsquery computer -inactive 4 # Computers inactive 4+ weeks
dsquery * -filter "(objectClass=user)" -limit 0 # All users
Related: Dsquery Guide
dsacls - Display/Modify Permissions
Syntax:
dsacls objectDN [parameters]
Examples:
dsacls "CN=John Doe,OU=Users,DC=contoso,DC=com" # Show ACL
dsacls "OU=Sales,DC=contoso,DC=com" /G "contoso\HelpDesk:RPWP;pwdLastSet" # Grant password reset
Related: Dsacls Complete Guide
PowerShell Active Directory Module
Get-ADUser - Retrieve Users
Syntax:
Get-ADUser [parameters]
Examples:
Get-ADUser -Identity jdoe # Get specific user
Get-ADUser -Filter * -SearchBase "OU=Sales,DC=contoso,DC=com" # All users in OU
Get-ADUser -Filter {Enabled -eq $false} # Disabled users
For comprehensive AD coverage, see our Complete Active Directory Guide.
Quick Reference Tables
Top 50 CMD Commands
| Command | Description | Example |
|---|---|---|
cd | Change directory | cd C:\Windows |
dir | List directory | dir /A |
copy | Copy files | copy file.txt D:\ |
del | Delete files | del *.tmp |
mkdir | Create directory | mkdir NewFolder |
rmdir | Remove directory | rmdir /S folder |
type | Display file | type file.txt |
find | Find text in file | find "error" logfile.txt |
ping | Test connectivity | ping google.com |
ipconfig | IP configuration | ipconfig /all |
netstat | Network statistics | netstat -an |
tasklist | List processes | tasklist |
taskkill | Kill process | taskkill /IM notepad.exe |
systeminfo | System information | systeminfo |
chkdsk | Check disk | chkdsk C: /F |
sfc | System file checker | sfc /scannow |
shutdown | Shutdown computer | shutdown /s /t 0 |
gpupdate | Update group policy | gpupdate /force |
hostname | Display computer name | hostname |
whoami | Display current user | whoami |
[See our CMD tutorials for detailed guides on each command]
Top 100 PowerShell Cmdlets
| Cmdlet | Description | Example |
|---|---|---|
Get-ChildItem | List files/directories | Get-ChildItem -Recurse |
Get-Process | List processes | Get-Process |
Get-Service | List services | Get-Service |
Get-Content | Read file | Get-Content file.txt |
Set-Content | Write file | Set-Content file.txt "text" |
Copy-Item | Copy item | Copy-Item -Recurse |
Move-Item | Move item | Move-Item file.txt D:\ |
Remove-Item | Delete item | Remove-Item -Recurse |
Get-Command | List commands | Get-Command *Process* |
Get-Help | Get help | Get-Help Get-Process |
Get-Member | Object members | Get-Process | Get-Member |
Where-Object | Filter objects | Where-Object {$_.CPU -gt 100} |
Select-Object | Select properties | Select-Object Name, CPU |
Sort-Object | Sort objects | Sort-Object CPU -Descending |
ForEach-Object | Loop objects | ForEach-Object {$_.Name} |
Test-Connection | Ping | Test-Connection google.com |
Get-ADUser | Get AD user | Get-ADUser -Identity jdoe |
New-ADUser | Create AD user | New-ADUser -Name "John Doe" |
Set-ADUser | Modify AD user | Set-ADUser -Identity jdoe |
Get-ADComputer | Get AD computer | Get-ADComputer -Filter * |
[See our PowerShell tutorials for 200+ detailed cmdlet guides]
Command Equivalents
File Operations Across Platforms
| Task | Windows (CMD) | PowerShell | Linux (Bash) |
|---|---|---|---|
| List files | dir | Get-ChildItem | ls |
| Copy file | copy src dst | Copy-Item src dst | cp src dst |
| Move file | move src dst | Move-Item src dst | mv src dst |
| Delete file | del file | Remove-Item file | rm file |
| View file | type file | Get-Content file | cat file |
| Find text | find "text" file | Select-String "text" file | grep "text" file |
| Create folder | mkdir folder | New-Item -ItemType Directory | mkdir folder |
| Remove folder | rmdir /S folder | Remove-Item -Recurse | rm -rf folder |
| Change dir | cd path | Set-Location path | cd path |
| Print dir | cd | Get-Location | pwd |
Frequently Asked Questions
Q: What’s the difference between CMD and PowerShell?
A: CMD is the legacy Windows command line (from 1981), text-based and limited. PowerShell (2006+) is a modern automation framework, object-based with extensive scripting capabilities. For new projects, use PowerShell;it’s more powerful, has better scripting, and works cross-platform (PowerShell 7+).
Q: How do I run PowerShell scripts?
A: Save code as .ps1 file, then run: .\script.ps1. You may need to set execution policy first: Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
Q: Can I use Linux commands on Windows?
A: Yes, via Windows Subsystem for Linux (WSL). Install from Microsoft Store: wsl --install. This provides a full Linux environment on Windows.
Q: How do I find what a command does?
A:
- CMD:
commandname /?(e.g.,dir /?) - PowerShell:
Get-Help cmdletname(e.g.,Get-Help Get-Process) - Bash:
man commandorcommand --help
Q: How do I redirect output to a file?
A:
- CMD/Bash:
command > file.txt(overwrite) orcommand >> file.txt(append) - PowerShell:
command | Out-File file.txtorcommand >> file.txt
Related Resources
Windows Command Line
- CMD Tutorials - 26 detailed CMD guides
- PowerShell Tutorials - 200+ PowerShell guides
- PowerShell Complete Guide - Comprehensive PowerShell tutorial
Active Directory
- Active Directory Guide - Complete AD tutorial
- Active Directory Tools - AD management tools
- Dsquery Examples - AD query commands
- Dsacls Guide - AD permissions management
Last Updated: February 4, 2026
About: This command line reference is maintained by ActiveDirectoryTools.net to help IT professionals quickly find command syntax and examples across Windows and Linux platforms.
Use the search function (Ctrl+F) to quickly find specific commands. Bookmark this page for quick reference!