Cheatsheets / Cross-OS lookup
Cross-OS lookup
Same task, three OSes
50 everyday tasks with the equivalent command on Linux, macOS, and Windows PowerShell. Search or filter by category, then copy the command you need.
No tasks match your search.
| Task | Linux | macOS | Windows (PowerShell) |
|---|---|---|---|
| Find what is using a port Networking `ss` is Linux-only; macOS falls back to `lsof`. | sudo ss -tulpn | grep :3000 | sudo lsof -i :3000 | Get-Process -Id (Get-NetTCPConnection -LocalPort 3000).OwningProcess |
| Kill a process by PID Processes | kill -9 1234 | kill -9 1234 | Stop-Process -Id 1234 -Force |
| Kill a process by name Processes | killall node | killall node | Stop-Process -Name node -Force |
| List running processes Processes | ps aux | ps aux | Get-Process |
| List all environment variables Environment | env | env | Get-ChildItem Env: |
| Set an env var for the current session Environment | export API_KEY=abc123 | export API_KEY=abc123 | $env:API_KEY = "abc123" |
| Check disk usage of a directory Disk | du -sh dir/ | du -sh dir/ | (Get-ChildItem dir -Recurse | Measure-Object -Property Length -Sum).Sum / 1GB |
| Check free disk space Disk | df -h | df -h | Get-Volume |
| Find files by name Files | find . -name "*.log" | find . -name "*.log" | Get-ChildItem -Recurse -Filter "*.log" |
| Search text inside files Files | grep -rn "TODO" . | grep -rn "TODO" . | Get-ChildItem -Recurse | Select-String "TODO" |
| Check your machine's IP address Networking Legacy fallback everywhere: `ipconfig` (Windows) shows the same info faster for a quick check. | ip addr show | ifconfig | Get-NetIPAddress |
| DNS lookup for a domain Networking `dig` is not installed by default on Windows; `nslookup` works cross-platform as a fallback. | dig example.com +short | dig example.com +short | Resolve-DnsName example.com |
| List installed services System | systemctl list-units --type=service | launchctl list | Get-Service |
| Restart a service System | sudo systemctl restart nginx | brew services restart nginx | Restart-Service -Name nginx |
| Tail a log file live Files | tail -f app.log | tail -f app.log | Get-Content app.log -Wait -Tail 10 |
| Check file permissions Files | ls -la file.txt | ls -la file.txt | Get-Acl file.txt |
| Change file permissions Files | chmod 755 script.sh | chmod 755 script.sh | icacls script.sh /grant User:F |
| Archive a folder Files | tar -czvf archive.tar.gz dir/ | tar -czvf archive.tar.gz dir/ | Compress-Archive -Path dir -DestinationPath archive.zip |
| Extract an archive Files | tar -xzvf archive.tar.gz | tar -xzvf archive.tar.gz | Expand-Archive -Path archive.zip -DestinationPath dest |
| Download a file from a URL Networking | curl -O https://example.com/file.zip | curl -O https://example.com/file.zip | Invoke-WebRequest -Uri https://example.com/file.zip -OutFile file.zip |
| Check OS version System | uname -a | sw_vers | [Environment]::OSVersion |
| Check CPU and memory usage live System | top | top -o cpu | Get-Process | Sort-Object CPU -Descending | Select-Object -First 10 |
| Copy a file to a remote server Networking OpenSSH (and `scp`) ships identically on all three once installed - no PowerShell-specific equivalent needed. | scp file.txt user@host:/path/ | scp file.txt user@host:/path/ | scp file.txt user@host:/path/ |
| Test connectivity to a host Networking | ping -c 4 example.com | ping -c 4 example.com | Test-Connection example.com -Count 4 |
| Test if a specific port is reachable Networking | nc -zv example.com 443 | nc -zv example.com 443 | Test-NetConnection example.com -Port 443 |
| List listening ports Networking | ss -tulpn | lsof -i -P | grep LISTEN | Get-NetTCPConnection -State Listen |
| Trace the network route to a host Networking | traceroute example.com | traceroute example.com | tracert example.com |
| Copy to the clipboard from the terminal Files `xclip` is not installed by default on most Linux distros - install it first (`apt install xclip`). | xclip -selection clipboard < file.txt | pbcopy < file.txt | Get-Content file.txt | Set-Clipboard |
| Open the current directory in the file browser Files | xdg-open . | open . | explorer . |
| Check which shell you are running Environment | echo $SHELL | echo $SHELL | $PSVersionTable.PSEdition |
| Create a symbolic link Files | ln -s target linkname | ln -s target linkname | New-Item -ItemType SymbolicLink -Path linkname -Target target |
| Count lines in a file Files | wc -l file.txt | wc -l file.txt | (Get-Content file.txt).Count |
| Show command history Environment | history | history | Get-History |
| Find a file's full path Files BSD `readlink` on macOS lacks `-f`; install GNU coreutils (`brew install coreutils`) for `greadlink -f`, or use `realpath` if already installed. | realpath file.txt | greadlink -f file.txt | (Get-Item file.txt).FullName |
| Check installed package manager version System | apt --version | brew --version | winget --version |
| Update all system packages System | sudo apt update && sudo apt upgrade | brew update && brew upgrade | winget upgrade --all |
| Check the current working directory Files | pwd | pwd | Get-Location |
| Rename a file Files | mv old.txt new.txt | mv old.txt new.txt | Rename-Item old.txt new.txt |
| Create a directory (with parents) Files | mkdir -p a/b/c | mkdir -p a/b/c | New-Item -ItemType Directory -Path a\b\c -Force |
| Delete a directory and its contents Files | rm -rf dir/ | rm -rf dir/ | Remove-Item dir -Recurse -Force |
| Show the difference between two files Files | diff -u old.txt new.txt | diff -u old.txt new.txt | Compare-Object (Get-Content old.txt) (Get-Content new.txt) |
| Check uptime System | uptime | uptime | (Get-CimInstance Win32_OperatingSystem).LastBootUpTime |
| Flush the DNS cache Networking | sudo systemd-resolve --flush-caches | sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder | ipconfig /flushdns |
| Check your public IP address Networking | curl -4 ifconfig.me | curl -4 ifconfig.me | Invoke-RestMethod ifconfig.me |
| Run a command as administrator/root System | sudo <command> | sudo <command> | Start-Process <command> -Verb RunAs |
| List block devices / disks Disk | lsblk | diskutil list | Get-Disk |
| Check listening services with their names System | systemctl list-units --type=service --state=running | launchctl list | grep -v "^-" | Get-Service | Where-Object Status -eq Running |
| View a file one page at a time Files | less file.txt | less file.txt | Get-Content file.txt | Out-Host -Paging |
| Check current user Environment | whoami | whoami | whoami |
| Generate an SSH key pair Networking OpenSSH tooling is identical across all three once installed. | ssh-keygen -t ed25519 -C "you@example.com" | ssh-keygen -t ed25519 -C "you@example.com" | ssh-keygen -t ed25519 -C "you@example.com" |