Skip to main content

Complete Command Line Reference: CMD, PowerShell & Bash Commands [2026]

10 min read
command line cmd commands powershell commands bash commands windows commands command reference terminal shell scripting system administration

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

  1. Introduction to Command Lines
  2. CMD vs PowerShell vs Bash
  3. Essential CMD Commands
  4. Essential PowerShell Cmdlets
  5. Bash Commands for Windows
  6. File Operations
  7. Directory Management
  8. Network Commands
  9. System Information
  10. User & Permission Management
  11. Active Directory Commands
  12. Process Management
  13. Quick Reference Tables
  14. Command Equivalents
  15. 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

  1. CMD (Command Prompt): Legacy Windows command line
  2. PowerShell: Modern Windows automation framework
  3. Bash: Unix/Linux shell (available on Windows via WSL)

CMD vs PowerShell vs Bash

Feature Comparison

FeatureCMDPowerShellBash
PlatformWindows onlyWindows, Linux, macOSUnix/Linux/macOS, WSL
Release198120061989
ScriptingBatch files (.bat)Scripts (.ps1)Shell scripts (.sh)
Object ModelText-basedObject-basedText-based
AliasesLimitedExtensiveExtensive
Remote ManagementLimitedBuilt-in (PS Remoting)SSH
Package ManagerNonePowerShellGetapt, 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

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:

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:

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

TaskCMDPowerShellBash
List filesdirGet-ChildItemls -la
Copy filecopy file.txt dest\Copy-Item file.txt dest\cp file.txt dest/
Move filemove file.txt dest\Move-Item file.txt dest\mv file.txt dest/
Delete filedel file.txtRemove-Item file.txtrm file.txt
View filetype file.txtGet-Content file.txtcat file.txt
Find filesdir /S /B *.txtGet-ChildItem -Recurse -Filter *.txtfind . -name "*.txt"
File sizedir file.txt(Get-Item file.txt).Lengthls -lh file.txt

Directory Management

Quick Reference Table

TaskCMDPowerShellBash
Current directorycdGet-Locationpwd
Change directorycd pathSet-Location pathcd path
Create directorymkdir folderNew-Item -ItemType Directorymkdir folder
Remove directoryrmdir /S folderRemove-Item -Recurserm -rf folder
List directoriesdir /ADGet-ChildItem -Directoryls -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

CommandDescriptionExample
cdChange directorycd C:\Windows
dirList directorydir /A
copyCopy filescopy file.txt D:\
delDelete filesdel *.tmp
mkdirCreate directorymkdir NewFolder
rmdirRemove directoryrmdir /S folder
typeDisplay filetype file.txt
findFind text in filefind "error" logfile.txt
pingTest connectivityping google.com
ipconfigIP configurationipconfig /all
netstatNetwork statisticsnetstat -an
tasklistList processestasklist
taskkillKill processtaskkill /IM notepad.exe
systeminfoSystem informationsysteminfo
chkdskCheck diskchkdsk C: /F
sfcSystem file checkersfc /scannow
shutdownShutdown computershutdown /s /t 0
gpupdateUpdate group policygpupdate /force
hostnameDisplay computer namehostname
whoamiDisplay current userwhoami

[See our CMD tutorials for detailed guides on each command]

Top 100 PowerShell Cmdlets

CmdletDescriptionExample
Get-ChildItemList files/directoriesGet-ChildItem -Recurse
Get-ProcessList processesGet-Process
Get-ServiceList servicesGet-Service
Get-ContentRead fileGet-Content file.txt
Set-ContentWrite fileSet-Content file.txt "text"
Copy-ItemCopy itemCopy-Item -Recurse
Move-ItemMove itemMove-Item file.txt D:\
Remove-ItemDelete itemRemove-Item -Recurse
Get-CommandList commandsGet-Command *Process*
Get-HelpGet helpGet-Help Get-Process
Get-MemberObject membersGet-Process | Get-Member
Where-ObjectFilter objectsWhere-Object {$_.CPU -gt 100}
Select-ObjectSelect propertiesSelect-Object Name, CPU
Sort-ObjectSort objectsSort-Object CPU -Descending
ForEach-ObjectLoop objectsForEach-Object {$_.Name}
Test-ConnectionPingTest-Connection google.com
Get-ADUserGet AD userGet-ADUser -Identity jdoe
New-ADUserCreate AD userNew-ADUser -Name "John Doe"
Set-ADUserModify AD userSet-ADUser -Identity jdoe
Get-ADComputerGet AD computerGet-ADComputer -Filter *

[See our PowerShell tutorials for 200+ detailed cmdlet guides]


Command Equivalents

File Operations Across Platforms

TaskWindows (CMD)PowerShellLinux (Bash)
List filesdirGet-ChildItemls
Copy filecopy src dstCopy-Item src dstcp src dst
Move filemove src dstMove-Item src dstmv src dst
Delete filedel fileRemove-Item filerm file
View filetype fileGet-Content filecat file
Find textfind "text" fileSelect-String "text" filegrep "text" file
Create foldermkdir folderNew-Item -ItemType Directorymkdir folder
Remove folderrmdir /S folderRemove-Item -Recurserm -rf folder
Change dircd pathSet-Location pathcd path
Print dircdGet-Locationpwd

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 command or command --help

Q: How do I redirect output to a file?

A:

  • CMD/Bash: command > file.txt (overwrite) or command >> file.txt (append)
  • PowerShell: command | Out-File file.txt or command >> file.txt

Windows Command Line

Active Directory


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!