CMD, PowerShell, Git Bash and Linux Terminal Workflow Guide
Good troubleshooting is not only about knowing commands. It is about choosing the right shell, collecting evidence in a safe order and leaving a repeatable trail for the next person. This guide shows how to move between Windows CMD, PowerShell, Git Bash and Linux without turning a simple incident into guesswork.
Which shell should you use?
| Shell | Best use | Watch out for |
|---|---|---|
| CMD | Legacy Windows commands, quick network checks, old batch scripts and vendor instructions that still use .bat files. | Text parsing is limited; prefer PowerShell for structured output. |
| PowerShell | Windows services, processes, firewall checks, path discovery, JSON handling and repeatable admin scripts. | Some Linux-style examples need translation because aliases can hide different behavior. |
| Git Bash | Git-heavy work, SSH keys, Unix-like commands on Windows and scripts shared with Linux users. | Windows paths and permissions can behave differently from real Linux hosts. |
| Linux shell | Server services, packages, logs, ports, storage, database clients and automation on production-like systems. | Use read-only discovery before package, firewall or service changes. |
Start every incident with environment facts
Before changing anything, capture where you are. A DBA should know the host, OS, shell, user, current path, IP information and time. These commands are safe discovery checks.
:: CMD
hostname
whoami
cd
ver
ipconfig /all
where git# PowerShell
$PSVersionTable.PSVersion
hostname
whoami
Get-Location
Get-ComputerInfo | Select-Object OsName, OsVersion, CsName
Get-Command git -ErrorAction SilentlyContinue# Git Bash or Linux
pwd
whoami
hostname
uname -a
cat /etc/os-release 2>/dev/null
command -v gitNetwork and port checks
When an application or database is unreachable, separate DNS, routing, firewall and service listener problems. Do not jump straight to restarting services.
# PowerShell
Resolve-DnsName example.com
Test-NetConnection example.com -Port 443
Test-NetConnection db.example.internal -Port 5432# Linux
getent hosts example.com
curl -I https://example.com
ss -tulpn
sudo ss -tulpn | grep -E ':(22|80|443|5432|3306|1433)\b'Service and log checks
For Linux servers, systemctl and journalctl should be the default path before editing config files. You want status, recent errors and restart history.
# Linux service inspection
systemctl status postgresql --no-pager
systemctl status mysql --no-pager
systemctl status nginx --no-pager
journalctl -u postgresql -n 80 --no-pager
journalctl -p warning -n 100 --no-pagerOn Windows, a DBA often needs service state and process ownership before touching database settings.
# PowerShell service inspection
Get-Service | Where-Object {$_.Name -match 'sql|postgres|mysql|oracle'}
Get-Process | Sort-Object CPU -Descending | Select-Object -First 10
Get-EventLog -LogName Application -Newest 50Storage checks for DBAs
Many database incidents are storage incidents wearing an application costume. Always check free space, mounts, inode pressure and the location of data and backups.
# Linux storage discovery
df -h
df -ih
lsblk
mount | column -t
du -sh /var/lib/postgresql /var/lib/mysql /var/log 2>/dev/null# PowerShell disk discovery
Get-Volume
Get-PSDrive -PSProvider FileSystem
Get-ChildItem C:\ -Directory | Sort-Object LastWriteTime -Descending | Select-Object -First 20Git Bash for repeatable handoffs
Git Bash is useful when Windows users need to run familiar Git and SSH commands. For a DBA, it is often enough for repository checks, deployment notes and controlled script review.
# Git Bash
git status
git log --oneline -5
git remote -v
ssh -V
ssh user@server.example.com
scp ./sanitized-query.sql user@server.example.com:/tmp/DBA troubleshooting order
- Identify the host, shell, user, environment and current time.
- Check DNS, route and port reachability before changing a service.
- Check service status and recent logs before editing configuration.
- Check disk, mounts and backup paths before tuning the database.
- Sanitize commands and payloads before sharing them in tickets or chat.
- Use a browser console such as Cockpit when a team needs a safer visual overview of Linux services, storage and logs.
A terminal workflow should make the next action safer. If a command would change packages, firewall rules, services, data files or database state, write down the expected result first.
Related Formalint tools
Use SQL Formatter for query readability, API Debugging Checklist for incident notes, Timestamp Converter for log times, Regex Log Parser for semi-structured logs and Linux Cockpit Server Guide for browser-based Linux administration.