Quick Reference

Cheatsheets

Practical command references for Linux, networking, servers, containers, databases, and more.

Cheatsheet#powershell-cheatsheet

PowerShell Cheatsheet

PowerShell is a cross-platform task automation solution made up of a command-line shell, a scripting language, and a configuration management framework.

Installation (Linux)

PowerShell Core (version 6+) is cross-platform.

# Debian / Ubuntu
sudo apt install wget apt-transport-https software-properties-common
wget -q "https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/packages-microsoft-prod.deb"
sudo dpkg -i packages-microsoft-prod.deb
sudo apt update
sudo apt install powershell
 
# RHEL / CentOS
sudo curl -L "https://packages.microsoft.com/config/rhel/8/prod.repo" -o /etc/yum.repos.d/microsoft.repo
sudo dnf install powershell
 
# Run PowerShell
pwsh

Many standard Linux commands (ls, cd, rm) work in PowerShell because they are mapped as aliases to PowerShell cmdlets.

# List files and directories
Get-ChildItem               # Alias: ls, dir
 
# Change directory
Set-Location C:\Windows     # Alias: cd
 
# Create a new directory or file
New-Item -ItemType Directory -Name "MyFolder" # Alias: mkdir
New-Item -ItemType File -Name "file.txt"      # Alias: touch
 
# Copy item
Copy-Item source.txt dest.txt # Alias: cp, copy
 
# Move item
Move-Item old.txt new.txt     # Alias: mv, move
 
# Remove item
Remove-Item file.txt          # Alias: rm, del
Remove-Item folder -Recurse   # Remove folder recursively

Process Management

# List running processes
Get-Process                 # Alias: ps
 
# Stop a process
Stop-Process -Name "chrome" # Stops all instances of Chrome
Stop-Process -Id 1234       # Alias: kill

Services Management

# List all services
Get-Service
 
# Start/Stop/Restart a service
Start-Service -Name "Spooler"
Stop-Service -Name "Spooler"
Restart-Service -Name "Spooler"

Network Information

# Get IP Configuration
Get-NetIPAddress            # Modern equivalent of ipconfig
Get-NetAdapter              # List network adapters
 
# Test connectivity (Ping)
Test-Connection google.com
 
# Test a specific port
Test-NetConnection -ComputerName example.com -Port 443

System Information

# Get system uptime
(Get-Date) - (Get-CimInstance Win32_OperatingSystem).LastBootUpTime
 
# Get general system info
Get-ComputerInfo