Troubleshooting cloud VMs — Essential Linux commands for cloud engineers
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.
| Category | Command | What It Tells You |
|---|---|---|
| CPU / Memory | top -bn1 | head -10 | CPU and memory hogs |
| Disk Space | df -h | Disk space usage per mount point |
| Disk I/O | iostat -x 1 5 | Disk throughput and IOPS |
| Memory | free -h | Total / used / free RAM and swap |
| Processes | ps aux --sort=-%mem | head -10 | Top processes by memory usage |
| Failed Services | systemctl --failed | List failed systemd units |
| Service Logs | journalctl -u docker -n 50 | Last 50 lines of Docker logs |
| Listening Ports | ss -tulpn | All listening TCP/UDP ports with process name |
| Network Reachability | ping -c 2 google.com | External connectivity check |
| DNS Resolution | nslookup api.internal.example.com | DNS resolution test |
| App Health | curl -v http://localhost:8080/health | Application health check |
| Cloud Metadata | curl -H Metadata-Flavor:Google http://metadata.google.internal/computeMetadata/v1/instance/ | GCP instance metadata (identity, zone, tags) |
| Open File Descriptors | lsof | wc -l | Count of open file descriptors (ulimit check) |
| Kernel Messages | dmesg -T | tail -20 | Recent kernel messages (OOM, hardware errors) |
| Network Stats | netstat -s | Network statistics summary (errors, retransmits) |
| Security Module | getenforce / aa-status | SELinux / AppArmor status |
# 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 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
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
Guest Agent: google-guest-agent (SSH keys, disk resize)
Serial Console: gcloud CLI access
Metadata: metadata.google.internal
Ops Agent: Unified logging + metrics agent