Essential DevOps Commands Reference

TL;DR: Quick reference guide for commonly used DevOps commands including SSH, Supervisord, Redis, MySQL, Docker, and ADB for mobile device management

A comprehensive quick reference for essential commands used in day-to-day DevOps operations, from service management to mobile device provisioning.

Service Management with Supervisord

┌─────────────────────────────────────────────────────────────┐
│                  SUPERVISORD COMMANDS                        │
├─────────────────────────────────────────────────────────────┤
│                                                             │
│  List all services:    sudo supervisorctl                   │
│  Status check:         sudo supervisorctl status            │
│  Start service:        sudo supervisorctl start <name>      │
│  Stop service:         sudo supervisorctl stop <name>       │
│  Restart service:      sudo supervisorctl restart <name>    │
│  Reload config:        sudo supervisorctl reread && update  │
│                                                             │
└─────────────────────────────────────────────────────────────┘

Interactive Mode

$ sudo supervisorctl
supervisor> status
xxx-service                      RUNNING   pid 1234, uptime 2:30:45
yyy-service                    RUNNING   pid 1235, uptime 2:30:42
zzz-service                STOPPED   Jun 21 02:30 PM

supervisor> start zzz-service
zzz-service: started

supervisor> tail -f xxx-service stdout
[following log output...]

supervisor> exit

SSH Access

Using SSH Key

# Standard SSH with key
ssh -i /path/to/your/ssh/key ubuntu@172.xx.xx.xx

# Example
ssh -i ~/.ssh/id_rsa ubuntu@172.xx.xx.49

Using PEM File

# For Ubuntu-based EC2 instances
sudo ssh -i ~/path/to/Dev_Key.pem ubuntu@172.xx.xx.xx

# For Amazon Linux EC2 instances
ssh -i ~/path/to/DevOps_key.pem ec2-user@172.xx.xx.xx

Adding SSH Keys for Authorization

# Edit authorized_keys to add new public keys
sudo vim ~/.ssh/authorized_keys

# Append the public key on a new line
# ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQ... user@hostname

MySQL Operations

# Start MySQL
sudo /etc/init.d/mysql start

# Stop MySQL
sudo /etc/init.d/mysql stop

# Restart MySQL
sudo /etc/init.d/mysql restart

# Check status
sudo /etc/init.d/mysql status

Alternative Systemctl Commands

sudo systemctl start mysql
sudo systemctl stop mysql
sudo systemctl restart mysql
sudo systemctl status mysql

Redis Operations

Key Management

# Connect to Redis
redis-cli

# Delete a specific key
DEL FV_12345

# Delete multiple keys
DEL PI_12345 FV_12345 VW_12345 VI_12345

# Get all members of a set
SMEMBERS FV_12345

# Delete pattern-based keys for Always-On data
DEL AlwaysOn_12345

Bulk Operations

# Find and delete keys matching pattern
redis-cli KEYS "FV_*" | xargs redis-cli DEL

# Count keys matching pattern
redis-cli KEYS "AlwaysOn_*" | wc -l

# Flush entire database (caution!)
redis-cli FLUSHDB

Docker Commands

Container Management

# List running containers
docker ps

# List all containers (including stopped)
docker ps -a

# Start/Stop/Restart
docker start <container_name>
docker stop <container_name>
docker restart <container_name>

# View logs
docker logs -f <container_name> --tail 100

# Execute command in container
docker exec -it <container_name> /bin/bash

Image Management

# Pull image
docker pull <image>:<tag>

# List images
docker images

# Remove image
docker rmi <image_id>

# Build image
docker build -t <name>:<tag> .

Android Debug Bridge (ADB)

Device Owner Management

# Set device as Corporate-Owned Single-Use (COSU)
adb shell dpm set-device-owner com.example.app/.DeviceAdminReceiver

# Remove device owner
adb shell dpm remove-active-admin com.example.app/.DeviceAdminReceiver

APK Management

# Install APK
adb install path/to/app.apk

# Force reinstall
adb install -r path/to/app.apk

# Uninstall app
adb uninstall com.example.app

# Get APK checksum (SHA-512)
shasum -a 512 path/to/app.apk

Device Operations

# List connected devices
adb devices

# Reboot device
adb reboot

# Access shell
adb shell

# Push file to device
adb push local/file.txt /sdcard/

# Pull file from device
adb pull /sdcard/file.txt local/

JIRA Query Examples

Sprint Task Queries

-- Planned tasks for sprint
project = PRJ AND issuetype in (Epic, "Field Bug", Story, Task, Sub-task) 
AND Sprint = 672 ORDER BY created DESC

-- Spillover tasks (tasks in multiple sprints)
project = PRJ AND issuetype in (Epic, "Field Bug", Story, Task, Sub-task) 
AND (Sprint = 659 AND Sprint = 636) ORDER BY created DESC

-- My open tasks
project = PRJ AND assignee = currentUser() 
AND status NOT IN (Done, Closed) ORDER BY priority DESC

Network Diagnostics

# Check if port is listening
netstat -tlnp | grep <port>
ss -tlnp | grep <port>

# Test connectivity
curl -v http://service:port/health

# DNS lookup
nslookup hostname
dig hostname

# Trace route
traceroute hostname

Log Analysis Quick Reference

# Tail last 100 lines
tail -100 /var/log/application.log

# Follow log in real-time
tail -f /var/log/application.log

# Search for errors
grep -i "error" /var/log/application.log

# Search with context (3 lines before/after)
grep -B3 -A3 "exception" /var/log/application.log

# Count occurrences
grep -c "ERROR" /var/log/application.log

# Search across multiple files
grep -r "pattern" /var/log/

Quick Reference Card

┌────────────────────────────────────────────────────────────┐
│                    COMMAND QUICK REFERENCE                  │
├────────────────────────────────────────────────────────────┤
│                                                            │
│  SERVICE MANAGEMENT                                        │
│  ─────────────────                                         │
│  supervisorctl status          List all services           │
│  supervisorctl restart <svc>   Restart service             │
│  systemctl status <service>    Check systemd service       │
│                                                            │
│  DATABASE                                                  │
│  ────────                                                  │
│  mysql -u root -p              Connect to MySQL            │
│  redis-cli                     Connect to Redis            │
│                                                            │
│  CONTAINERS                                                │
│  ──────────                                                │
│  docker ps                     List containers             │
│  docker logs -f <name>         Follow logs                 │
│  docker exec -it <name> bash   Shell into container        │
│                                                            │
│  DEBUGGING                                                 │
│  ─────────                                                 │
│  curl -v <url>                 Verbose HTTP request        │
│  netstat -tlnp                 List listening ports        │
│  tail -f /var/log/<file>       Follow log file             │
│                                                            │
└────────────────────────────────────────────────────────────┘

Bookmark this reference for quick access during operational tasks and incident response.