Day 6 - Shell Scripting & Linux Interview Questions for DevOps Engineers
Hi there! I'm Dinesh, a passionate Cloud and DevOps enthusiast. I love to dive into the latest new technologies and sharing my journey through blog.
Search for a command to run...
Hi there! I'm Dinesh, a passionate Cloud and DevOps enthusiast. I love to dive into the latest new technologies and sharing my journey through blog.
No comments yet. Be the first to comment.
1. Difference between Docker and Kubernetes Docker → Builds and runs containers.Kubernetes → Orchestrates containers across multiple nodes. Key points: Docker = container runtime. Kubernetes = container orchestration tool. Kubernetes provides auto...
In this session, we learn how to monitor a Kubernetes cluster using Prometheus and Grafana.This is not just theory — there is a GitHub repository containing all installation commands and demo steps.The repo will also be enhanced later with advanced K...
1. What is a ConfigMap in Kubernetes? A ConfigMap is used to store non-sensitive configuration data that your application needs — such as: Database port Connection type Any general configuration values In normal applications (non-Kubernetes), de...
Kubernetes normally supports built-in resources like: Deployment Service Pod ConfigMap Secret Ingress These are called native resources. Sometimes companies (Istio, ArgoCD, Prometheus Operator, Kyverno, etc.) want to add new features that Kub...
1. Why Kubernetes Services Are Needed When a Pod is created in Kubernetes, it receives a dynamic IP address.If the Pod dies and restarts, its IP changes.So other Pods (like checkout → payments) cannot rely on Pod IP because it changes, creating issue...
Answer:
“In my day-to-day DevOps work, I mostly use basic operational commands such as:
ls — list files
cp, mv — copy and move files
mkdir, touch — create directories and files
vim — edit files
grep, awk, sed — filtering and text processing
find — search for files
df, du — disk usage
top, ps — process monitoring
tail -f — read logs in real-time
Advanced debugging commands like netcat, traceroute, route I use only during troubleshooting.”
Script:
#!/bin/bash
ps -ef
If asked to print only process IDs:
ps -ef | awk '{print $2}'
Answer:
“Using curl, grep, and a pipe.”
Example:
curl -s <remote_log_url> | grep "ERROR"
Script:
#!/bin/bash
for i in {1..100}
do
if { [ $((i % 3)) -eq 0 ] || [ $((i % 5)) -eq 0 ]; } \
&& [ $((i % 15)) -ne 0 ]; then
echo $i
fi
done
Script:
#!/bin/bash
word="Mississippi"
echo "$word" | grep -o "s" | wc -l
Answer:
“By enabling debug mode using set -x at the top of the script.
It prints each command before execution.”
set -x
Answer:
“Crontab is used to schedule recurring jobs in Linux, like backups, reports, cleanup, etc.”
Example: run a script every day at 6 PM
0 18 * * * /home/ubuntu/report.sh
vim -R filename
Points directly to the inode.
Original and link are identical.
If original file is deleted, data remains.
Cannot link directories.
Cannot link across different filesystems.
Acts like a shortcut referencing the path.
If original file is deleted, soft link breaks.
Can link directories.
Can link across filesystems.
Example:
Python → python3 alias is created using soft links.
Example use cases:
break: Stop when a condition is met.
continue: Skip unwanted values (e.g., skip multiples of 15).
Answer:
Not statically typed → variables can cause runtime errors.
Difficult to debug large scripts.
Poor error handling compared to modern languages.
No portability for platform-specific commands.
Complex logic becomes unreadable.
Slower execution vs. compiled languages.
for loop – iterate over range, list, or output
while loop – run until a condition is false
until loop – run until condition becomes true
select loop – menu based input
Answer:
“Bash is dynamically typed. Variables do not require data type declarations, and types are determined at runtime.”