Terminal & CLI
PowerShell, Windows Terminal, and command-line tools for Linux users transitioning to Windows environments.
Windows Terminal
Windows Terminal vs Linux Terminals
| Feature | Windows Terminal | Linux (GNOME Terminal) | Linux (Konsole) |
|---|---|---|---|
| Tabs | Yes | Yes | Yes |
| Split panes | Yes | Limited | Yes |
| Profiles | Multiple shells | One shell | Multiple profiles |
| Themes | JSON configuration | GUI settings | GUI settings |
| GPU acceleration | Yes | Limited | Yes |
| Background images | Yes | Limited | Yes |
Installing Windows Terminal
# Install from Microsoft Store (recommended)
# Or install via winget
winget install Microsoft.WindowsTerminal
# Or install via chocolatey
choco install microsoft-windows-terminal
Windows Terminal Shortcuts
| Action | Shortcut | Linux Equivalent |
|---|---|---|
| New tab | Ctrl + Shift + T | Ctrl + Shift + T |
| Close tab | Ctrl + Shift + W | Ctrl + Shift + W |
| Switch tabs | Ctrl + Tab | Ctrl + Page Up/Down |
| Split pane horizontally | Alt + Shift + - | Ctrl + Shift + O |
| Split pane vertically | Alt + Shift + + | Ctrl + Shift + E |
| Switch panes | Alt + Arrow keys | Alt + Arrow keys |
| New window | Ctrl + Shift + N | Ctrl + Shift + N |
| Copy | Ctrl + Shift + C | Ctrl + Shift + C |
| Paste | Ctrl + Shift + V | Ctrl + Shift + V |
Windows Terminal Configuration
Configuration is stored in JSON format (similar to VS Code):
%USERPROFILE%\AppData\Local\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json
Access settings: Ctrl + ,
PowerShell for Linux Users
PowerShell vs Bash Comparison
| Concept | PowerShell | Bash | Notes |
|---|---|---|---|
| Philosophy | Object-oriented | Text-based | PowerShell works with .NET objects |
| Case sensitivity | Case-insensitive | Case-sensitive | Commands and parameters |
| Variables | $variable | $variable | Similar syntax |
| Command output | Objects | Text | Major difference |
| Piping | Object properties | Text streams | Different capabilities |
| Help system | Get-Help | man | Built-in documentation |
PowerShell Command Structure
# Verb-Noun pattern
Get-Process # Like ps aux
Set-Location # Like cd
Copy-Item # Like cp
# Parameters
Get-Process -Name "chrome"
Get-ChildItem -Path "C:\" -Recurse
Basic Commands Translation
| Task | PowerShell | Bash | Alias Available |
|---|---|---|---|
| List files | Get-ChildItem | ls | ls, dir |
| Change directory | Set-Location | cd | cd |
| Copy files | Copy-Item | cp | cp, copy |
| Move files | Move-Item | mv | mv, move |
| Delete files | Remove-Item | rm | rm, del |
| Show content | Get-Content | cat | cat, type |
| Create directory | New-Item -ItemType Directory | mkdir | mkdir, md |
| Current location | Get-Location | pwd | pwd, gl |
| Process list | Get-Process | ps | ps |
| Find text | Select-String | grep | No direct alias |
PowerShell Aliases
PowerShell includes many Linux-like aliases:
# View all aliases
Get-Alias
# Common Linux aliases that work
ls # Get-ChildItem
pwd # Get-Location
cd # Set-Location
cp # Copy-Item
mv # Move-Item
rm # Remove-Item
cat # Get-Content
ps # Get-Process
kill # Stop-Process
Variables and Environment
| Task | PowerShell | Bash |
|---|---|---|
| Set variable | $var = "value" | var="value" |
| Use variable | $var | $var |
| Environment variable | $env:PATH | $PATH |
| Set env variable | $env:VAR = "value" | export VAR="value" |
| List env variables | Get-ChildItem env: | env or printenv |
PowerShell Object Pipeline
# Get processes, filter by CPU usage, select properties
Get-Process | Where-Object {$_.CPU -gt 10} | Select-Object Name, CPU
# Linux equivalent (text processing)
ps aux | awk '$3 > 10 {print $11, $3}'
PowerShell Scripting Basics
# Script file extension: .ps1
# Conditional
if ($condition) {
Write-Host "True"
} else {
Write-Host "False"
}
# Loop
foreach ($item in $collection) {
Write-Host $item
}
# Function
function Get-SystemInfo {
Get-ComputerInfo | Select-Object WindowsProductName, WindowsVersion
}
Command Prompt (Legacy)
Command Prompt vs PowerShell
| Feature | Command Prompt | PowerShell | Recommendation |
|---|---|---|---|
| Objects | No | Yes | Use PowerShell |
| Aliases | Limited | Extensive | Use PowerShell |
| Scripting | Batch files | PowerShell scripts | Use PowerShell |
| Error handling | Limited | Advanced | Use PowerShell |
| Help system | Basic | Comprehensive | Use PowerShell |
When to Use Command Prompt
- Legacy batch scripts
- System administration tools that require it
- Simple file operations (if you prefer)
Command Prompt Commands
| Task | Command | Linux Equivalent |
|---|---|---|
| Directory listing | dir | ls |
| Change directory | cd | cd |
| Copy files | copy | cp |
| Move files | move | mv |
| Delete files | del | rm |
| Create directory | mkdir | mkdir |
| Remove directory | rmdir | rmdir |
| Display file | type | cat |
Package Managers
Chocolatey (Third-party)
Windows package manager similar to apt/yum/pacman.
Installation:
Set-ExecutionPolicy Bypass -Scope Process -Force
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072
iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
Usage:
| Task | Chocolatey | Linux (apt) | Linux (yum) |
|---|---|---|---|
| Install package | choco install package | apt install package | yum install package |
| Uninstall package | choco uninstall package | apt remove package | yum remove package |
| Update package | choco upgrade package | apt upgrade package | yum update package |
| Update all | choco upgrade all | apt upgrade | yum update |
| Search package | choco search package | apt search package | yum search package |
| List installed | choco list --local-only | apt list --installed | yum list installed |
Windows Package Manager (winget)
Microsoft's official package manager.
Usage:
| Task | winget | Linux (apt) |
|---|---|---|
| Install | winget install package | apt install package |
| Uninstall | winget uninstall package | apt remove package |
| Update | winget upgrade package | apt upgrade package |
| Update all | winget upgrade --all | apt upgrade |
| Search | winget search package | apt search package |
| List | winget list | apt list --installed |
Scoop (Alternative package manager)
Focused on command-line tools and development software.
Installation:
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
irm get.scoop.sh | iex
Usage:
scoop install git
scoop install nodejs
scoop bucket add extras
scoop install vscode
File and Text Processing
PowerShell File Operations
# Read file content
Get-Content file.txt
# Write to file
"Hello World" | Out-File file.txt
# Append to file
"New line" | Add-Content file.txt
# Count lines
(Get-Content file.txt).Count
# Get file info
Get-ItemProperty file.txt
Text Processing Comparison
| Task | PowerShell | Linux |
|---|---|---|
| Search text | Select-String "pattern" file.txt | grep "pattern" file.txt |
| Replace text | (Get-Content file.txt) -replace "old", "new" | Set-Content file.txt | sed 's/old/new/g' file.txt |
| Count lines | (Get-Content file.txt).Count | wc -l file.txt |
| Sort lines | Get-Content file.txt | Sort-Object | sort file.txt |
| Unique lines | Get-Content file.txt | Sort-Object -Unique | sort -u file.txt |
| Head/tail | Get-Content file.txt -Head 10 / -Tail 10 | head -10 file.txt / tail -10 |
PowerShell CSV Processing
# Import CSV
$data = Import-Csv data.csv
# Filter and export
$data | Where-Object {$_.Status -eq "Active"} | Export-Csv filtered.csv
# Group and count
$data | Group-Object Department | Select-Object Name, Count
Network Commands
Network Diagnostics
| Task | Windows | Linux | PowerShell |
|---|---|---|---|
| Ping | ping hostname | ping hostname | Test-Connection hostname |
| Traceroute | tracert hostname | traceroute hostname | Test-NetConnection -TraceRoute |
| DNS lookup | nslookup hostname | dig hostname | Resolve-DnsName hostname |
| Network config | ipconfig | ifconfig / ip addr | Get-NetIPAddress |
| Network connections | netstat | netstat / ss | Get-NetTCPConnection |
| ARP table | arp -a | arp -a | Get-NetNeighbor |
PowerShell Network Commands
# Test network connectivity
Test-NetConnection google.com -Port 80
# Get network adapters
Get-NetAdapter
# Get IP configuration
Get-NetIPConfiguration
# Test DNS resolution
Resolve-DnsName google.com
# Get network statistics
Get-NetStatistics
System Information
System Information Commands
| Information | Windows | Linux | PowerShell |
|---|---|---|---|
| System info | systeminfo | uname -a | Get-ComputerInfo |
| Hardware info | msinfo32 | lshw | Get-WmiObject Win32_ComputerSystem |
| CPU info | wmic cpu get name | lscpu | Get-WmiObject Win32_Processor |
| Memory info | wmic memorychip get size | free -h | Get-WmiObject Win32_PhysicalMemory |
| Disk info | wmic logicaldisk get size,freespace | df -h | Get-WmiObject Win32_LogicalDisk |
| Process list | tasklist | ps aux | Get-Process |
| Service list | sc query | systemctl list-units | Get-Service |
PowerShell System Information
# Computer information
Get-ComputerInfo | Select-Object WindowsProductName, WindowsVersion, TotalPhysicalMemory
# Disk space
Get-WmiObject -Class Win32_LogicalDisk | Select-Object DeviceID, Size, FreeSpace
# Running processes
Get-Process | Sort-Object CPU -Descending | Select-Object -First 10
# System uptime
(Get-CimInstance Win32_OperatingSystem).LastBootUpTime
Remote Management
PowerShell Remoting
# Enable PS Remoting (run as administrator)
Enable-PSRemoting -Force
# Connect to remote computer
Enter-PSSession -ComputerName RemotePC
# Run command on remote computer
Invoke-Command -ComputerName RemotePC -ScriptBlock {Get-Process}
# Copy files to remote computer
Copy-Item -Path "local.txt" -Destination "\\RemotePC\C$\temp\" -ToSession $session
SSH on Windows
# Install OpenSSH Client (Windows 10/11)
Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0
# Connect via SSH
ssh username@hostname
# Copy files via SCP
scp file.txt username@hostname:/path/to/destination
Execution Policies and Security
PowerShell Execution Policies
| Policy | Description | Linux Equivalent |
|---|---|---|
| Restricted | No scripts allowed | No execute permission |
| RemoteSigned | Local scripts and signed remote scripts | Mixed permissions |
| Unrestricted | All scripts allowed | Execute permission |
# Check current policy
Get-ExecutionPolicy
# Set policy (as administrator)
Set-ExecutionPolicy RemoteSigned
# Bypass policy for single session
powershell -ExecutionPolicy Bypass -File script.ps1
Script Security
# Sign a script (requires code signing certificate)
Set-AuthenticodeSignature -FilePath script.ps1 -Certificate $cert
# Check script signature
Get-AuthenticodeSignature script.ps1
Terminal Customization
Windows Terminal Themes
{
"schemes": [
{
"name": "Linux-like",
"black": "#2e3436",
"red": "#cc0000",
"green": "#4e9a06",
"yellow": "#c4a000",
"blue": "#3465a4",
"purple": "#75507b",
"cyan": "#06989a",
"white": "#d3d7cf",
"brightBlack": "#555753",
"brightRed": "#ef2929",
"brightGreen": "#8ae234",
"brightYellow": "#fce94f",
"brightBlue": "#729fcf",
"brightPurple": "#ad7fa8",
"brightCyan": "#34e2e2",
"brightWhite": "#eeeeec",
"background": "#2e3436",
"foreground": "#d3d7cf"
}
]
}
PowerShell Profile Customization
# Check if profile exists
Test-Path $PROFILE
# Create profile
New-Item -ItemType File -Path $PROFILE -Force
# Edit profile
notepad $PROFILE
Example profile:
# PowerShell profile (~/.config/powershell/profile.ps1 equivalent)
# Set aliases
Set-Alias ll Get-ChildItem
Set-Alias la 'Get-ChildItem -Force'
# Custom prompt (like bash PS1)
function prompt {
$user = $env:USERNAME
$computer = $env:COMPUTERNAME
$path = $PWD.Path.Replace($HOME, "~")
"$user@$computer`:$path$ "
}
# Import modules
Import-Module posh-git # Git integration
Best Practices for Linux Users
Transition Tips
- Start with Windows Terminal: Modern terminal experience
- Use PowerShell: More powerful than Command Prompt
- Learn object pipeline: Different from text-based pipes
- Install package manager: Chocolatey or winget
- Set up SSH: For remote access
- Customize profile: Make it feel like home
- Use WSL when needed: For Linux tools and commands
Command Discovery
# Find commands
Get-Command *process*
# Get help
Get-Help Get-Process -Examples
# Find modules
Find-Module -Name "*git*"
# Discover object properties
Get-Process | Get-Member
Useful PowerShell Modules
| Module | Purpose | Installation |
|---|---|---|
| posh-git | Git integration | Install-Module posh-git |
| PSReadLine | Better command line editing | Built-in (Windows 10+) |
| Terminal-Icons | File type icons | Install-Module Terminal-Icons |
| z | Directory jumping | Install-Module z |
Performance Tips
- Use aliases: For frequently used commands
- Profile optimization: Don't load heavy modules unnecessarily
- Object filtering: Use
Where-Objectearly in pipelines - Background jobs: For long-running tasks
- ISE vs Terminal: Use appropriate tool for task