Linux Diagnostics

Troubleshooting cloud VMs — Essential Linux commands for cloud engineers

Concept

When troubleshooting cloud workloads, these Linux commands are the first line of defense — regardless of whether the VM runs on Azure, AWS, or GCP. The commands are identical across clouds.

Diagnostic Command Cheat Sheet

CategoryCommandWhat It Tells You
CPU / Memorytop -bn1 | head -10CPU and memory hogs
Disk Spacedf -hDisk space usage per mount point
Disk I/Oiostat -x 1 5Disk throughput and IOPS
Memoryfree -hTotal / used / free RAM and swap
Processesps aux --sort=-%mem | head -10Top processes by memory usage
Failed Servicessystemctl --failedList failed systemd units
Service Logsjournalctl -u docker -n 50Last 50 lines of Docker logs
Listening Portsss -tulpnAll listening TCP/UDP ports with process name
Network Reachabilityping -c 2 google.comExternal connectivity check
DNS Resolutionnslookup api.internal.example.comDNS resolution test
App Healthcurl -v http://localhost:8080/healthApplication health check
Cloud Metadatacurl -H Metadata-Flavor:Google http://metadata.google.internal/computeMetadata/v1/instance/GCP instance metadata (identity, zone, tags)
Open File Descriptorslsof | wc -lCount of open file descriptors (ulimit check)
Kernel Messagesdmesg -T | tail -20Recent kernel messages (OOM, hardware errors)
Network Statsnetstat -sNetwork statistics summary (errors, retransmits)
Security Modulegetenforce / aa-statusSELinux / AppArmor status

GCP-Specific Diagnostics

# Check if GCP guest agent is running
systemctl status google-guest-agent

# View serial console output (no SSH needed)
gcloud compute instances get-serial-port-output my-vm --zone=us-central1-a

# Check if OS Login is enabled
gcloud compute instances describe my-vm --zone=us-central1-a | grep enable-oslogin

# List all instance metadata
curl "http://metadata.google.internal/computeMetadata/v1/instance/?recursive=true" -H "Metadata-Flavor: Google"

# Test network connectivity to GCP APIs
curl -v https://storage.googleapis.com 2>&1 | head -5

# Check Ops Agent status (logging + metrics)
systemctl status google-cloud-ops-agent*

○ Azure — Azure Linux Diag

Azure Linux Agent: waagent
Serial Console: Available in portal (Boot Diagnostics)
Instance Metadata: curl -H Metadata:true http://169.254.169.254/metadata/instance
VM Insights: Azure Monitor agent

○ AWS — AWS Linux Diag

SSM Agent: Session Manager (no SSH required)
Instance Screenshot: EC2 Console
Metadata: curl http://169.254.169.254/latest/meta-data/
CloudWatch Agent: System + application metrics

○ GCP — GCP Linux Diag

Guest Agent: google-guest-agent (SSH keys, disk resize)
Serial Console: gcloud CLI access
Metadata: metadata.google.internal
Ops Agent: Unified logging + metrics agent