# DevOps Practical Questions with Production-Level Answers

Preparing for a DevOps interview at a product-based company requires more than memorising definitions. Interviewers want to understand how you troubleshoot production failures, design reliable infrastructure, secure deployment pipelines, and make decisions under pressure.

This article covers across Linux, Docker, Kubernetes, CI/CD, AWS, Terraform, monitoring, and production troubleshooting.

Every question follows an eight-attribute answer framework. Each attribute has its own heading, followed by a practical explanation to make revision easier.

Linux & Shell Scripting

Q1. How do you find which process is holding a port and kill it safely?

Simple Concept

A port is occupied by a process listening for network connections. You need to identify that process before stopping it.

Why Do We Need It?

This is useful when an application cannot start because its required port is already in use.

How Does It Work?

Linux networking utilities map listening ports to process IDs. Identify the process, inspect it, and terminate it gracefully.

Production Example

A Java application cannot start because port 8080 is already occupied by an older application instance.

Commands

sudo ss -lntp | grep :8080 sudo lsof -i :8080 ps -fp

# Graceful termination

sudo kill -15

# Force termination only if necessary

sudo kill -9

Common Interview Trap

Do not immediately use kill -9. It prevents graceful shutdown and may interrupt cleanup or data-writing operations.

Candidate-Style Answer

“I first identify the process using the port with ss or lsof. I inspect its command and ownership, verify whether it is managed by systemd, and then stop it gracefully. I use SIGKILL only if the process does not respond.”

Memory Trick

Find → Inspect → Stop → Verify.

Q2. What does load average really mean, and how do you read it against core count?

Simple Concept

Load average represents the average number of tasks running or waiting for CPU time, along with tasks in uninterruptible sleep, typically waiting for I/O.

Why Do We Need It?

It helps identify system pressure and determine whether the machine has sufficient processing capacity.

How Does It Work?

Linux displays load averages over 1-minute, 5-minute, and 15-minute periods. Compare these values with the number of CPU cores.

Production Example

An 8-core server has a load average of 18, but CPU utilization is only 45%. This could indicate processes blocked on disk or network I/O rather than pure CPU saturation.

Commands

uptime top nproc vmstat 1 iostat -xz 1

Common Interview Trap

High load average does not always mean high CPU utilization. I/O wait and blocked tasks can also increase load.

Candidate-Style Answer

“I compare the load average with available CPU cores and investigate CPU utilization, I/O wait, and blocked processes. I use top, vmstat, and iostat to identify the actual bottleneck.”

Memory Trick

Load = Running work + Waiting work. Compare it with cores.

Q3. How do you keep a long job running after logout and surviving a reboot?

Simple Concept

Tools such as nohup, tmux, and screen keep processes running after a terminal session ends. They do not automatically guarantee survival after a reboot.

Why Do We Need It?

Long-running scripts, data processing jobs, backups, and deployments should not depend on an active SSH session.

How Does It Work?

nohup ignores the hangup signal.

tmux and screen allow sessions to be detached and reattached.

systemd manages services and can restart them after reboot.

Production Example

A data-processing script takes several hours. Running it as a systemd service makes it easier to manage, monitor, and restart.

Commands

nohup ./backup.sh > backup.log 2>&1 &

Example systemd service:

\[Unit\] Description=Backup Job

\[Service\] ExecStart=/opt/scripts/backup.sh Restart=on-failure

\[Install\] WantedBy=multi-user.target

sudo systemctl enable backup.service sudo systemctl start backup.service

Common Interview Trap

nohup protects against terminal logout, not machine reboot. Use a service manager or scheduler for reboot recovery.

Candidate-Style Answer

“For temporary jobs, I use nohup or tmux. For production workloads that must survive reboots and support automatic restart, I configure a systemd service or a proper job scheduler.”

Memory Trick

Logout survival: nohup. Reboot survival: systemd.

Docker & Containers

Q4. How do you debug a container that repeatedly exits or restarts?

Simple Concept

A container exits when its main process terminates. Restart policies or orchestration platforms may start it again.

Why Do We Need It?

Repeated restarts can cause application downtime and indicate configuration, dependency, resource, or application failures.

How Does It Work?

Inspect the container’s state, exit code, logs, configuration, and resource limits. Identify whether the failure originates inside the application or its environment.

Production Example

A Python container repeatedly exits because its database connection string is missing.

Commands

docker ps -a docker logs &lt;container_id> docker inspect &lt;container_id> docker stats docker events

Check exit code and restart count:

docker inspect\
\--format='{{.State.ExitCode}} {{.RestartCount}}'\
&lt;container_id>

Common Interview Trap

Restarting the container repeatedly does not fix the underlying problem. An exited container may also not appear in the default docker ps output.

Candidate-Style Answer

“I inspect the container status and exit code, check application logs, review environment variables and mounted volumes, and investigate resource constraints. Once I identify the root cause, I fix the configuration or application issue before restarting it.”

Memory Trick

Status → Logs → Inspect → Resources → Fix.

Q5. Explain multi-stage builds and how they shrink the final image.

Simple Concept

Multi-stage builds use multiple FROM instructions in a Dockerfile. Build tools and temporary dependencies stay in the build stage, while only required application artifacts are copied into the runtime stage.

Why Do We Need It?

Smaller images reduce storage consumption, transfer time, attack surface, and deployment overhead.

How Does It Work?

The first stage compiles or builds the application. The final stage contains only the runtime and required artifacts.

Production Example

A Java application is compiled using Maven, but the production image contains only the generated JAR and a Java runtime.

Dockerfile

FROM maven:3.9-eclipse-temurin-17 AS build

WORKDIR /app COPY pom.xml . COPY src ./src

RUN mvn clean package -DskipTests

FROM eclipse-temurin:17-jre

WORKDIR /app COPY --from=build /app/target/\*.jar app.jar

USER 10001

ENTRYPOINT \["java", "-jar", "app.jar"\]

Common Interview Trap

Multi-stage builds do not automatically guarantee a secure image. You still need to scan dependencies, use trusted base images, and run as a non-root user.

Candidate-Style Answer

“I use a separate build stage containing compilers and dependencies, then copy only the final artifact into a minimal runtime image. This reduces image size and limits unnecessary packages in production.”

Memory Trick

Build everything. Ship only what you need.

Kubernetes

Q6. Explain readiness, liveness and startup probes, and how you debug a failing one.

Simple Concept

Kubernetes probes determine whether a container has started correctly, is alive, and is ready to receive traffic.

Why Do We Need It?

They prevent traffic from reaching unready applications and help Kubernetes recover from unhealthy processes.

How Does It Work?

Startup probe: Determines whether the application has completed startup.

Readiness probe: Determines whether the application can receive traffic.

Liveness probe: Determines whether the application should be restarted.

Production Example

A Java application takes 90 seconds to start. A startup probe gives it enough time before liveness checks begin. Readiness prevents traffic from reaching it until initialization is complete.

YAML Example

startupProbe: httpGet: path: /health port: 8080 failureThreshold: 30 periodSeconds: 5

readinessProbe: httpGet: path: /ready port: 8080 periodSeconds: 10

livenessProbe: httpGet: path: /health port: 8080 periodSeconds: 15

Debugging commands:

kubectl describe pod kubectl logs kubectl get events --sort-by=.lastTimestamp

Common Interview Trap

Readiness failure removes a Pod from Service endpoints. Liveness failure can restart the container. They are not interchangeable.

Candidate-Style Answer

“I use startup probes for applications with slow initialization, readiness probes to control traffic eligibility, and liveness probes to recover from unrecoverable application states. I investigate probe events, endpoint paths, ports, timeouts, and application logs before changing thresholds.”

Memory Trick

Startup = Started? Readiness = Ready for traffic? Liveness = Still alive?

Q7. How do you perform a zero-downtime deployment and a rollback with Helm?

Simple Concept

Helm manages Kubernetes application releases using charts. Rolling updates and carefully configured readiness checks can help deploy new versions without interrupting service.

Why Do We Need It?

Production deployments must minimize downtime and provide a reliable way to return to a previous working release.

How Does It Work?

A new release is deployed using updated chart values. Kubernetes gradually replaces old Pods while checking readiness. If the new version fails, the previous Helm revision can be restored.

Production Example

An application has four replicas. During an update, Kubernetes keeps healthy old Pods serving traffic while new Pods become ready.

Commands

helm upgrade myapp ./chart\
\-n production\
\--install\
\--wait\
\--timeout 5m

helm history myapp -n production

helm rollback myapp 3\
\-n production\
\--wait

Deployment strategy:

strategy: type: RollingUpdate rollingUpdate: maxUnavailable: 0 maxSurge: 1

Common Interview Trap

A Helm rollback does not automatically reverse database schema changes or external side effects. Application and database compatibility must be planned separately.

Candidate-Style Answer

“I configure rolling updates, readiness probes, sufficient replicas, and appropriate resource limits. I deploy using Helm with health checks and wait conditions. If validation fails, I inspect the release history and roll back to the last known-good revision.”

Memory Trick

Deploy → Verify → Monitor → Roll Back if needed.

CI/CD

Q8. How do you implement secure pipelines with approvals, artifact management and rollback?

Simple Concept

A secure CI/CD pipeline automates software delivery while enforcing security checks, controlled approvals, traceable artifacts, and recovery procedures.

Why Do We Need It?

It prevents untested, vulnerable, or unauthorized code from reaching production.

How Does It Work?

A typical workflow includes source checkout, unit tests, security scanning, image building, artifact publishing, approval, deployment, and post-deployment validation.

Production Example

A developer pushes code. The pipeline runs tests and security scans, publishes an immutable image, and waits for production approval before deployment.

Practical Security Measures

Use short-lived credentials through OIDC where supported.

Store secrets in a secrets manager.

Pin dependencies and trusted base images.

Generate SBOMs and scan artifacts.

Use immutable image tags or digests.

Restrict production deployment permissions.

Common Interview Trap

A successful build does not mean a secure release. Security checks and deployment authorization must be enforced separately.

Candidate-Style Answer

“I implement automated testing and security scans before artifact publishing. I use immutable artifacts, approval gates for production, least-privilege deployment credentials, and a tested rollback mechanism. Every release should be traceable to its source commit and artifact.”

Memory Trick

Test → Scan → Store → Approve → Deploy → Verify.

Q9. How do you make a slow pipeline fast without losing safety?

Simple Concept

Pipeline optimization reduces unnecessary execution time while preserving testing, security, and release quality.

Why Do We Need It?

Slow pipelines delay feedback, reduce engineering productivity, and increase deployment lead time.

How Does It Work?

Run independent jobs in parallel.

Cache dependencies safely.

Use incremental builds.

Avoid unnecessary image rebuilds.

Use efficient Docker layer ordering.

Run fast tests before expensive integration tests.

Reuse immutable artifacts between stages.

Production Example

A 25-minute pipeline spends 10 minutes installing dependencies and 8 minutes running independent test suites sequentially. Dependency caching and parallel execution can reduce that delay.

Example

jobs: unit-tests: runs-on: ubuntu-latest steps: - run: pytest tests/unit

security-scan: runs-on: ubuntu-latest steps: - run: trivy fs --exit-code 1 .

These jobs can run in parallel when their dependencies allow it.

Common Interview Trap

Do not remove tests or security scans just to improve pipeline speed. Faster delivery is not useful if it increases production risk.

Candidate-Style Answer

“I first analyze pipeline execution time and identify bottlenecks. Then I introduce parallel jobs, dependency caching, incremental builds, and artifact reuse. I measure the improvement while ensuring all required quality gates remain active.”

Memory Trick

Measure → Identify → Parallelize → Cache → Validate.

AWS & Infrastructure

Q10. Explain IAM roles, instance profiles and least privilege for services.

Simple Concept

IAM roles provide temporary permissions to AWS services and workloads. An instance profile is the container used to pass an IAM role to an EC2 instance.

Why Do We Need It?

It allows applications to access AWS services without embedding long-lived access keys.

How Does It Work?

An EC2 instance receives an IAM role through an instance profile. Applications use the AWS SDK or CLI to obtain temporary credentials from the instance metadata service.

Production Example

An EC2-hosted application needs to read objects from a specific S3 bucket. Instead of storing access keys, attach a role that grants only the required S3 permissions.

Example IAM Policy

{ "Version": "2012-10-17", "Statement": \[ { "Effect": "Allow", "Action": \["s3:GetObject"\], "Resource": "arn:aws:s3:::my-app-bucket/\*" } \] }

Common Interview Trap

An IAM role and an instance profile are not the same thing. The instance profile is the mechanism used by EC2 to associate a role with an instance.

Candidate-Style Answer

“I attach an IAM role to the EC2 instance through an instance profile. The application retrieves temporary credentials automatically. I follow least privilege by restricting permissions to the exact actions and resources required.”

Memory Trick

Role = Permissions. Instance profile = EC2 delivery mechanism.

Q11. How does an instance access object storage without static access keys?

Simple Concept

An EC2 instance can access Amazon S3 using temporary credentials supplied through an attached IAM role.

Why Do We Need It?

Static credentials stored in application code or configuration files can leak and are difficult to rotate safely.

How Does It Work?

The EC2 instance uses its IAM role to obtain temporary credentials from the instance metadata service. AWS SDKs automatically retrieve and refresh these credentials.

Production Example

A backup service running on EC2 uploads backup files to a specific S3 bucket without storing access keys.

Commands

aws sts get-caller-identity aws s3 ls s3://my-app-bucket/

Common Interview Trap

Do not confuse an IAM role with an access key. The role provides temporary credentials, not permanent credentials embedded in the application.

Candidate-Style Answer

“I attach an IAM role to the EC2 instance with the required S3 permissions. The AWS SDK automatically uses temporary credentials from instance metadata, eliminating the need for static access keys.”

Memory Trick

Attach role → Get temporary credentials → Access S3.

Terraform & Infrastructure as Code

Q12. How do you keep secrets out of the Terraform state file?

Simple Concept

Terraform state can contain sensitive values, even when variables or outputs are marked as sensitive.

Why Do We Need It?

State files may contain passwords, tokens, private keys, and infrastructure metadata. Exposing them can create serious security risks.

How Does It Work?

Use secure remote backends, encryption, restricted access, and external secrets management. Avoid passing secrets as ordinary hardcoded values.

Production Example

An application database password is retrieved from AWS Secrets Manager rather than committed to a Terraform configuration file.

Example

data "aws_secretsmanager_secret_version" "db" { secret_id = "production/database" }

Remote state backend example:

terraform { backend "s3" { bucket = "company-terraform-state" key = "production/terraform.tfstate" region = "ap-south-1" encrypt = true use_lockfile = true } }

Common Interview Trap

Marking a variable as sensitive = true hides it in normal CLI output, but does not guarantee that its value is excluded from state.

Candidate-Style Answer

“I use a secure remote backend with encryption and strict access controls. I retrieve secrets from a secrets manager, avoid hardcoding them, and restrict state access to authorized automation roles. I also understand that sensitive Terraform values can still be stored in state.”

Memory Trick

Sensitive output does not mean secret-free state.

Q13. Terraform taint vs import: What does each do?

Simple Concept

Terraform import brings an existing infrastructure resource under Terraform management. The traditional terraform taint command marks a resource for replacement.

Why Do We Need It?

Import helps manage manually created infrastructure. Taint was used to force recreation when a resource needed replacement.

How Does It Work?

Import: Associates an existing resource with a Terraform resource address.

Taint: Marks a managed resource for replacement during a later plan and apply.

Production Example

An AWS S3 bucket was created manually. You want Terraform to manage it without recreating it. Import the bucket into state and then align the configuration with the actual resource.

Commands

terraform import\
aws_s3_bucket.app\
my-existing-bucket

Traditional taint command:

terraform taint aws_instance.web

Modern replacement workflow:

terraform plan\
\-replace="aws_instance.web"

Common Interview Trap

terraform import does not automatically generate a complete Terraform configuration. You still need to write the resource configuration and verify that it matches the imported infrastructure.

Also, terraform taint is deprecated in modern Terraform workflows. Prefer -replace.

Candidate-Style Answer

“Import brings an existing resource into Terraform state so it can be managed as infrastructure as code. Taint historically marked a resource for recreation. In current workflows, I use the -replace option to explicitly request replacement.”

Memory Trick

Import = Adopt existing resource. Replace = Recreate managed resource.

Monitoring & Observability

Q14. How do you trace a slow request across microservices?

Simple Concept

Distributed tracing follows a request as it travels across multiple services and identifies where latency is introduced.

Why Do We Need It?

A request may pass through an API gateway, authentication service, payment service, and database. Application logs alone may not reveal which component is slow.

How Does It Work?

A trace contains multiple spans. Each span represents an operation within a service. Trace context is propagated between services so the complete request path can be reconstructed.

Production Example

A payment API takes 4 seconds to respond. Distributed tracing reveals that the payment service takes 300 ms, but a downstream database query takes 3.2 seconds.

Tools

OpenTelemetry for instrumentation and context propagation.

Jaeger or Tempo for trace storage and visualization.

Prometheus for metrics.

Grafana for dashboards.

Loki or Elasticsearch for logs.

Common Interview Trap

Metrics show that latency increased. Traces help identify where the latency occurred. Logs provide detailed event context. These signals complement each other.

Candidate-Style Answer

“I instrument services with OpenTelemetry and propagate trace context across service boundaries. I inspect trace spans to identify slow dependencies, correlate them with metrics and logs, and then investigate the specific service or database operation causing latency.”

Memory Trick

Metrics = What happened? Logs = What was recorded? Traces = Where did it happen?

Q15. How do you design monitoring and alerting with Prometheus and Grafana?

Simple Concept

Prometheus collects and stores time-series metrics. Grafana visualizes those metrics through dashboards and alerts.

Why Do We Need It?

Monitoring helps teams identify availability, performance, capacity, and reliability issues before they become major incidents.

How Does It Work?

Applications expose metrics.

Prometheus scrapes metric endpoints.

PromQL queries analyze the data.

Grafana displays dashboards.

Alert rules trigger notifications through Alertmanager.

Production Example

A Kubernetes application starts returning more HTTP 5xx responses. Prometheus detects the increase and Alertmanager sends an alert to the on-call engineer.

Example PromQL

sum(rate(http_requests_total{status=~"5.."}\[5m\])) / sum(rate(http_requests_total\[5m\]))

This calculates the proportion of HTTP 5xx requests over the selected five-minute window, assuming the application exposes the required labels and metric.

Common Interview Trap

A dashboard is not an alerting strategy. Alerts should be actionable and tied to user impact or meaningful operational thresholds.

Candidate-Style Answer

“I monitor application availability, request latency, error rates, infrastructure utilization, and Kubernetes health. Prometheus collects metrics, Grafana provides dashboards, and Alertmanager routes actionable alerts to the appropriate teams.”

Memory Trick

Collect → Query → Visualize → Alert → Respond.

Scenario-Based Questions

Q16. A production app goes down right after a deploy. How do you investigate and restore it?

Simple Concept

This is a production incident requiring rapid service restoration followed by root-cause analysis.

Why Do We Need It?

Every deployment carries some risk. A reliable DevOps engineer must know how to limit impact and recover safely.

How Does It Work?

Confirm the outage and its scope.

Check deployment history.

Inspect application and infrastructure health.

Review logs, events, and metrics.

Compare the new and previous versions.

Roll back if the release is responsible.

Validate service recovery.

Production Example

A new application version is deployed to Kubernetes. Pods become unhealthy and users start receiving HTTP 503 errors. The team identifies a configuration issue and rolls back the release.

Commands

kubectl get pods -n production kubectl get deploy -n production

kubectl get events -n production\
\--sort-by=.lastTimestamp

kubectl logs deployment/myapp\
\-n production

kubectl rollout history deployment/myapp\
\-n production

kubectl rollout undo deployment/myapp\
\-n production

Common Interview Trap

Do not spend too much time debugging while users continue experiencing an outage. Restoration and investigation should happen in parallel where possible.

Candidate-Style Answer

“My first priority is to understand the impact and restore service. I check the deployment history, Pod health, application logs, and recent configuration changes. If the new release is responsible and rollback is safe, I restore the previous stable version. After recovery, I investigate the root cause and document preventive actions.”

Memory Trick

Impact → Investigate → Restore → Validate → Prevent.

Q17. A pod works in staging but crashes in production. Where do you look?

Simple Concept

An application behaving differently across environments usually indicates differences in configuration, permissions, dependencies, resources, or infrastructure.

Why Do We Need It?

Staging and production environments may differ in traffic, secrets, network policies, resource limits, service dependencies, and deployment configuration.

How Does It Work?

Compare the environments systematically:

Environment variables and ConfigMaps.

Secret references and permissions.

Image tags and image digests.

CPU and memory requests and limits.

Service accounts and IAM permissions.

Network policies and DNS.

Database connectivity.

Probe configuration.

Node architecture and scheduling constraints.

Production Example

A Pod works in staging but crashes in production because the production database password was rotated while the Kubernetes Secret still contains the old value.

Commands

kubectl get pod -n production -o wide

kubectl describe pod\
\-n production

kubectl logs\
\-n production --previous

kubectl get events -n production\
\--sort-by=.lastTimestamp

kubectl describe configmap\
\-n production

kubectl get secret\
\-n production

Avoid printing secret values into terminal logs or interview screenshots.

Common Interview Trap

Do not assume that the application image is faulty just because the Pod crashes. Environment-specific configuration, permissions, resource constraints, and external dependencies are frequent causes.

Candidate-Style Answer

“I compare the staging and production configurations, inspect Pod events and previous container logs, and verify secrets, resource limits, service account permissions, DNS, and network connectivity. I isolate the difference responsible for the failure and apply the smallest safe correction.”

Memory Trick

Config → Secrets → Resources → Permissions → Network → Dependencies.

Final Interview Preparation Checklist

Before attending a DevOps interview, make sure you can confidently explain these areas.

Linux and Shell

Process and port troubleshooting.

CPU, memory, disk, and load average analysis.

Background jobs and systemd.

Docker

Container lifecycle and restart troubleshooting.

Multi-stage builds.

Image optimization and security.

Kubernetes

Probes and application health.

Helm deployments and rollbacks.

Pod scheduling, networking, and debugging.

CI/CD

Secure pipeline design.

Artifact management.

Approval gates and pipeline optimization.

AWS

IAM roles and instance profiles.

Temporary credentials.

Least-privilege access.

Terraform

State security.

Import and resource replacement.

Infrastructure lifecycle management.

Observability

Distributed tracing.

Metrics, logs, and dashboards.

Actionable alerts.

How to Stand Out in DevOps Interview

Do not answer every question with a definition. Connect your explanation to an actual engineering situation.

Instead of simply saying, “I know Kubernetes rollback,” explain:

“In one deployment scenario, if a new release causes readiness failures or increased 5xx responses, I check rollout status, Pod events, and application logs. If the release is responsible, I restore the previous stable revision and verify service recovery through health checks and monitoring.”

That is the difference between knowing a command and understanding how to operate a production system.

My recommendation: Practise these questions using the eight-attribute framework. Focus especially on Kubernetes troubleshooting, secure CI/CD, Terraform state management, AWS IAM, and observability.

The strongest candidates are not the ones who remember the most commands. They are the ones who can explain what they would do when something breaks in production.
