Chapter 70: DevOps Interview Questions by Topic and Company
70.1 Linux, Shell Scripting and Networking Interview Questions
Linux, bash aani networking - pratyek DevOps interview chi suruvat ithun hote. Command chalvun dakhva, uttar lakshat rahil.
What you will learn in this lesson
- 67 real Linux, Shell Scripting and Networking questions with short answers
- Which companies asked them, from public interview stories
- Fresher, experienced and senior levels
- A simple way to answer: why, what, how
Why: the problem
Every DevOps interview starts with Linux. The server is down, the disk is full, or SSH fails. They want to see if you can find the problem with simple commands.
What: how to read this lesson
Each question has a short answer in three parts.
- Why: the reason the thing exists.
- What: the plain meaning.
- How: how you use it, often with a small command.
"Asked at" names a company only when a public interview story says the question was asked there. No tag means it is a common question that many companies ask.
Companies with the most questions in this lesson: Amazon (17), Google (12), Wipro (10), Tech Mahindra (5), LTIMindtree (5), HCLTech (2).
How: answer any question in 4 steps
- Start with the reason. One sentence.
- Give the plain meaning. No big words.
- Show one command or file.
- Add one example from your work. Then stop and wait.
Fresher questions
Q1. How do you add a user and give sudo access?
Why: Common admin task.
What: useradd creates the user; adding to the sudo/wheel group gives admin rights.
sudo useradd -m -s /bin/bash ravi
sudo usermod -aG sudo ravi
Q2. How do you check the OS version and kernel?
Why: First step on a new server.
What: /etc/os-release shows the OS; uname shows the kernel.
cat /etc/os-release
uname -r
Q3. How do you check memory usage?
Why: Basic health check.
What: free -h shows used, free, cache and swap.
How: "available" is the real number to watch.
free -h
Q4. How do you check running processes in Linux?
Why: You must know what is running before you can fix a slow server.
What: A process is a running program with an ID (PID).
How: Use ps aux for a snapshot, top or htop for a live view, and pgrep to find a PID by name.
ps aux | grep nginx
top
pgrep -a java
Q5. What is the difference between top, htop and ps?
Why: Each tool answers a different question.
What: ps prints a one-time list. top shows a live, refreshing list. htop is a friendlier top with colours and mouse support.
How: Use ps in scripts, top on any server, htop when it is installed.
ps -ef --sort=-%mem | head
htop
Q6. How do you schedule a cron job every 15 minutes?
Why: Many jobs (backups, cleanups) must run on a timer.
What: cron runs commands on a schedule written in five time fields.
How: Run crontab -e and add a line with */15 in the minute field.
*/15 * * * * /opt/scripts/cleanup.sh >> /var/log/cleanup.log 2>&1
Q7. What is the difference between a hard link and a soft link?
Why: Links let one file have two names.
What: A hard link is a second name for the same inode (same data). A soft (symbolic) link is a small file that points to a path.
How: If you delete the original, a hard link still works but a soft link breaks. Soft links can cross file systems and point to folders.
ln file.txt hard.txt
ln -s /etc/nginx/nginx.conf nginx.conf
ls -li
Q8. How do you find which process is using the most memory?
Why: High memory makes servers slow or kills apps.
What: Each process shows its memory use in %MEM and RSS.
How: Sort ps by memory, or press Shift+M inside top.
ps aux --sort=-%mem | head -5
free -h
Q9. What happens when you run chmod 755 on a file?
Why: Permissions decide who can read, write or run a file.
What: 7 = read+write+execute for the owner; 5 = read+execute for group and others.
How: Use 755 for scripts and folders. Use 644 for normal files. Never use 777 on a server.
chmod 755 deploy.sh
ls -l deploy.sh
-rwxr-xr-x 1 ravi ravi 120 deploy.sh
Q10. How do you find files larger than 1 GB?
Why: Big files fill the disk and stop the app.
What: find can search by size.
How: Search from / and hide permission errors.
sudo find / -type f -size +1G -exec ls -lh {} \; 2>/dev/null
Q11. What is the difference between grep, awk and sed?
Why: All three work on text, which is most of a log file.
What: grep finds lines. awk works on columns. sed edits text (find and replace).
How: Chain them: grep the lines, awk the column, sed to clean up.
grep ERROR app.log
awk '{print $1}' access.log | sort | uniq -c
sed -i 's/8080/9090/' app.conf
Q12. What Linux commands do you use daily?
Why: Interviewers want to see real habits, not a list.
What: The daily set covers files, processes, disk, network and logs.
How: Mention: ls, cd, cat, less, tail -f, grep, ps, top, df -h, du -sh, free -h, ss -tulpn, systemctl, journalctl, curl.
tail -f /var/log/nginx/error.log
systemctl status nginx
Q13. Explain some useful options of the ls command.
Why: ls is the first command on every server.
What: Options change what ls shows.
How: -l long list, -a hidden files, -h human sizes, -t sort by time, -r reverse, -i show inode.
ls -lahtr /var/log
Q14. Explain different use cases of grep.
Why: grep is the fastest way to search logs.
What: grep prints lines that match a pattern.
How: -i ignore case, -v invert, -r recursive, -n line numbers, -c count, -E regex, -B/-A lines before/after.
grep -rn "timeout" /etc/nginx/
grep -c " 500 " access.log
grep -B2 -A2 Exception app.log
Q15. How do you check disk usage and free space?
Why: A full disk is a top cause of outages.
What: df shows space per file system. du shows space used by folders.
How: Use df -h first, then du on the full mount to find the big folder.
df -h
sudo du -sh /var/* | sort -h | tail
Q16. How do you check the performance of a Linux server?
Why: A slow app often means a busy server.
What: Look at CPU, memory, disk I/O and network.
How: Use uptime (load), top, free -h, vmstat 1, iostat -x 1, and ss -s.
uptime
vmstat 1 5
iostat -x 1 3
Q17. Your system is running slow. How will you troubleshoot it?
Why: Interviewers want a calm, ordered method.
What: Slowness comes from CPU, memory, disk, network or the app itself.
How: 1) uptime for load. 2) top for the busy process. 3) free -h for memory and swap. 4) iostat for disk. 5) check app logs.
uptime; top; free -h; iostat -x 1
Q18. How do you create and view a file in Linux?
Why: Basic, but freshers are asked this often.
What: touch creates an empty file; cat, less, head and tail show it.
How: Use an editor (vim/nano) or echo with > to write.
touch notes.txt
echo "hello" > notes.txt
cat notes.txt
Q19. Which command shows the first 5 lines of a file?
Why: You often peek at big files.
What: head shows the start, tail shows the end.
How: Use -n to choose the number of lines. tail -f follows a growing log.
head -n 5 app.log
tail -n 20 -f app.log
Q20. What does the top command show?
Why: top is the live health screen of a server.
What: The header shows uptime, load average, tasks, CPU split (us, sy, id, wa, st) and memory. The list shows processes.
How: Press P to sort by CPU, M by memory, k to kill, 1 to see each core.
Q21. What are the different Linux distributions?
Why: Commands differ a little between families.
What: Debian family: Ubuntu, Debian (apt). Red Hat family: RHEL, CentOS Stream, Rocky, Amazon Linux (dnf/yum). Others: Alpine (apk), SUSE (zypper).
How: Name the one you used and its package manager.
cat /etc/os-release
Q22. What is the /proc file system?
Why: It shows live kernel and process data.
What: /proc is a virtual file system; its files are created by the kernel in memory.
How: Read /proc/cpuinfo, /proc/meminfo, or /proc/<PID>/ for one process.
cat /proc/meminfo | head -3
ls /proc/1/
Q23. What is systemd and how do you manage a service?
Why: Every server app runs as a service.
What: systemd is the first process (PID 1). It starts and watches services.
How: Use systemctl to start, stop, enable at boot and check status; journalctl to read logs.
sudo systemctl enable --now nginx
systemctl status nginx
journalctl -u nginx -f
Q24. What is the difference between a process and a thread?
Why: It explains how apps use CPU.
What: A process has its own memory. Threads live inside a process and share its memory.
How: Threads are lighter to start; a bug in one thread can crash the whole process.
ps -eLf | head
Q25. What is swap memory?
Why: It explains why a server becomes very slow.
What: Swap is disk space used as extra memory when RAM is full.
How: Some swap is fine; heavy swapping means you need more RAM or a leak fix.
free -h
swapon --show
Q26. How do you check logs on a Linux server?
Why: Logs tell you what went wrong.
What: Logs live in /var/log or in the systemd journal.
How: Use tail -f, less, grep, and journalctl -u <service>.
sudo tail -f /var/log/syslog
journalctl -u docker --since "1 hour ago"
Q27. What is umask?
Why: It sets default permissions for new files.
What: umask removes bits from 666 (files) and 777 (folders).
How: With umask 022, new files get 644 and folders 755.
umask
umask 027
Q28. Write a shell script to delete log files older than 7 days.
Why: Old logs fill the disk.
What: find can select files by age and delete them.
How: Test with -print first, then use -delete. Run it from cron daily.
#!/bin/bash
find /var/log/myapp -name "*.log" -mtime +7 -print -delete
Q29. Write a shell script to find the factorial of a number.
Why: It checks loops and arithmetic in bash.
What: Factorial n! = 1 × 2 × ... × n.
How: Read the number, loop, and multiply.
#!/bin/bash
n=$1; f=1
for ((i=2;i<=n;i++)); do f=$((f*i)); done
echo "$n! = $f"
Q30. What kind of bash scripts have you written in your project?
Why: They want real examples, not theory.
What: Typical scripts: backups, log cleanup, health checks, deploy steps, user creation.
How: Name 2-3 with what they did and how they were triggered (cron or pipeline).
Q31. What is the difference between $@ and $*?
Why: Scripts often pass arguments on.
What: Both mean all arguments. "$@" keeps each argument separate; "$*" joins them into one string.
How: Use "$@" almost always.
for a in "$@"; do echo "$a"; done
Q32. What does set -euo pipefail do?
Why: It makes scripts stop on errors instead of continuing silently.
What: -e exits on error, -u errors on unset variables, -o pipefail fails a pipe if any part fails.
How: Put it at the top of every deploy script.
#!/bin/bash
set -euo pipefail
Q33. How do you check if a file exists in bash?
Why: Scripts must check before acting.
What: Test operators check files: -f file, -d folder, -e any.
How: Use if [ -f path ].
if [ -f /etc/app.conf ]; then echo found; fi
Q34. What is the exit status $?
Why: Pipelines decide pass or fail by exit codes.
What: $? holds the exit code of the last command: 0 = success, non-zero = error.
How: Check it after a command, or use && and ||.
ls /nofile; echo $?
make build && echo ok
Q35. What happens when you type a URL in the browser?
Why: It covers DNS, TCP, TLS and HTTP in one story.
What: 1) DNS turns the name into an IP. 2) TCP handshake. 3) TLS handshake for HTTPS. 4) HTTP request. 5) Server (via load balancer) replies. 6) Browser renders.
How: Explain each step briefly and say where things can fail.
curl -v https://example.com
Q36. What is DNS and why is it needed?
Why: People remember names, computers use IPs.
What: DNS is the internet phone book: it maps names to IP addresses.
How: Record types: A, AAAA, CNAME, MX, TXT, NS. Test with dig or nslookup.
dig +short google.com
nslookup ravindrabagale.com
Q37. How does DHCP work (DORA)?
Why: Every new machine needs an IP.
What: DORA = Discover, Offer, Request, Acknowledge.
How: The client broadcasts, the server offers an IP, the client requests it, the server confirms with a lease.
Q38. What is subnetting and why is it needed?
Why: Every AWS VPC design needs it.
What: Subnetting splits a big network into smaller ones. /24 = 256 addresses.
How: It separates public and private parts and controls traffic.
10.0.0.0/16 → 10.0.1.0/24 (public), 10.0.2.0/24 (private)
Q39. What is the difference between TCP and UDP?
Why: Choosing the right one matters for apps.
What: TCP is connection-based, ordered and reliable. UDP is connectionless and fast but may lose packets.
How: TCP: web, SSH, databases. UDP: DNS, video calls, streaming.
Q40. Which ports do HTTP, HTTPS, SSH and MySQL use?
Why: Firewalls and security groups need ports.
What: HTTP 80, HTTPS 443, SSH 22, MySQL 3306, PostgreSQL 5432, DNS 53, Prometheus 9090.
How: Open only what you need.
Q41. What commands do you use to troubleshoot network issues in Linux?
Why: Network problems look like app problems.
What: Each tool tests one layer.
How: ping (reach), traceroute (path), dig (DNS), nc -zv / telnet (port), curl -v (HTTP), ss (listening), ip a / ip r (config).
ping -c3 10.0.2.10
nc -zv db.local 3306
curl -I http://localhost:8080
Q42. What is a firewall?
Why: It is the first line of defence.
What: A firewall allows or blocks traffic by IP, port and protocol.
How: On Linux: ufw, firewalld, iptables/nftables. On AWS: security groups and NACLs.
sudo ufw allow 443/tcp
sudo ufw status
Q43. What is the difference between public and private IP?
Why: Every cloud setup uses both.
What: Public IPs are reachable from the internet. Private IPs (10.x, 172.16-31.x, 192.168.x) work inside a network.
How: Servers in private subnets reach the internet through a NAT gateway.
Q44. What is the difference between a load balancer at layer 4 and layer 7?
Why: Picking the right AWS load balancer depends on it.
What: Layer 4 works on IP and port (fast). Layer 7 reads HTTP (paths, hosts, headers).
How: AWS NLB is L4; ALB is L7.
Experienced questions (2-5 years)
Q45. What does strace do?
Why: Deep debugging.
What: strace shows system calls a process makes.
How: Use it to see which file or network call hangs.
strace -f -p 1234 -e trace=network
Q46. What is CPU steal time?
Why: Cloud VMs share hardware.
What: Steal (st in top) is time your VM waited for the physical CPU.
How: High steal means a noisy neighbour or small burstable instance; move or resize.
Q47. df shows the disk is 100% full but du shows only 30% used. Why?
Why: This puzzle is asked to test real experience.
What: A deleted file that a process still holds open is not seen by du, but its space is not freed.
How: Find it with lsof +L1, then restart the process or empty the file through /proc.
sudo lsof +L1
sudo systemctl restart myapp
Q48. What is an inode and what happens when inodes run out?
Why: You can get "No space left" even with free GB.
What: An inode stores a file's details (owner, size, where data is), not its name. Each file uses one.
How: Check with df -i. Millions of tiny files can use all inodes; delete them to recover.
df -i
sudo find /tmp -type f | wc -l
Q49. Explain the Linux boot process.
Why: Boot problems stop the whole server.
What: Firmware (BIOS/UEFI) → bootloader (GRUB) → kernel → initramfs → systemd (PID 1) → services → login prompt.
How: If it fails, read the console message, try the old kernel in GRUB, and check journalctl -b -1.
journalctl -b -1 -p err
systemctl --failed
Q50. You cannot create a file. Give at least three reasons.
Why: This tests how wide your thinking is.
What: Something blocks the write.
How: 1) No write permission on the folder. 2) Disk full. 3) Inodes full. 4) File system mounted read-only. 5) Immutable attribute (chattr +i).
ls -ld /data; df -h; df -i; mount | grep data; lsattr
Q51. What is load average and how does it relate to CPU cores?
Why: People misread load and panic.
What: Load is the average number of tasks running or waiting, over 1, 5 and 15 minutes.
How: Compare it to the core count (nproc). Load 4 on 4 cores is full; load 8 on 4 cores means tasks wait.
uptime
nproc
Q52. How do you check which ports are listening?
Why: A service that is not listening cannot get traffic.
What: Each server program listens on a port.
How: Use ss -tulpn (or netstat on old systems) and look for your port.
sudo ss -tulpn | grep :80
Q53. How do you troubleshoot an SSH connection failure?
Why: SSH is how we reach every server.
What: Failures come from network, firewall, the sshd service, keys or permissions.
How: 1) ping / nc -zv host 22. 2) Security group or firewall allows 22. 3) sshd running. 4) Right user and key, key file mode 400. 5) ssh -vvv for details.
ssh -vvv -i key.pem ec2-user@10.0.1.5
chmod 400 key.pem
Q54. What happens when you type ls in a shell?
Why: Google-style interviews ask about Linux internals.
What: The shell reads the line, checks aliases and built-ins, finds ls in PATH, forks a child, and the child runs execve.
How: ls reads the folder through system calls, prints, and exits; the shell waits and shows the prompt again.
strace -c ls
Q55. What is the difference between kill, kill -9 and kill -15?
Why: Stopping an app the wrong way can lose data.
What: kill sends a signal. 15 (SIGTERM) asks politely; 9 (SIGKILL) forces stop and cannot be caught.
How: Try SIGTERM first, wait, then SIGKILL only if needed.
kill -15 1234
sleep 10; kill -9 1234
Q56. What is LVM and why use it?
Why: Disks fill up; LVM lets you grow them.
What: LVM (Logical Volume Manager) groups disks into volume groups and cuts them into logical volumes.
How: You can extend a volume while online, then grow the file system.
sudo lvextend -L +10G /dev/vg0/data
sudo resize2fs /dev/vg0/data
Q57. What is the difference between sudo and su?
Why: Safe admin access matters in audits.
What: su switches to another user (needs that user's password). sudo runs one command as root (needs your password) and is logged.
How: Prefer sudo with limited rules in /etc/sudoers.
sudo visudo
Q58. What are good practices for Linux server hardening?
Why: Servers on the internet are attacked daily.
What: Hardening means reducing the ways in.
How: Disable root SSH and passwords, use keys, patch often, firewall only needed ports, least privilege, fail2ban, audit logs.
sudo sed -i 's/^#\?PermitRootLogin.*/PermitRootLogin no/' /etc/ssh/sshd_config
Q59. Write a bash script to check disk and CPU usage and alert.
Why: Simple monitoring scripts are common daily work.
What: Read df and top values and compare with a limit.
How: Print a warning (or send to Slack) when usage is high.
#!/bin/bash
d=$(df / --output=pcent | tail -1 | tr -dc 0-9)
c=$(top -bn1 | awk '/Cpu/{print 100-$8}')
[ "$d" -gt 80 ] && echo "Disk $d% high"
echo "CPU used: $c%"
Q60. Write a script to report the 10 biggest folders.
Why: Finding space hogs is a common task.
What: du measures folder size; sort ranks them.
How: Use du -sh, sort -h, and tail.
#!/bin/bash
du -sh /home/* 2>/dev/null | sort -h | tail -10
Q61. From a CSV (NAME,GENDER,CITY,AGE), print males from Toronto aged 30-40.
Why: Text processing with awk is a classic test.
What: awk can split by comma and test each field.
How: Set -F, skip the header, and check fields 2, 3, 4.
awk -F, 'NR>1 && $2=="M" && $3=="Toronto" && $4>=30 && $4<=40' people.csv
Q62. Write a script to find the most repeated phone number in a file.
Why: It tests sort and uniq.
What: Count each line and keep the top one.
How: Use grep to pull numbers, then sort
uniq -c | sort -nr. | grep -oE '[0-9]{10}' calls.txt | sort | uniq -c | sort -nr | head -1
Q63. Parse a log file and count error codes.
Why: Every on-call engineer does this.
What: Pick the field with the status code and count it.
How: Use awk to print the field, then sort and uniq -c.
awk '{print $9}' access.log | sort | uniq -c | sort -nr
Q64. Why does DNS mostly use UDP and not TCP?
Why: It tests protocol basics.
What: UDP is fast with no handshake, and most DNS answers fit in one packet.
How: DNS uses TCP for large answers and zone transfers. Port 53 for both.
Q65. Explain the TCP three-way handshake and connection close.
Why: Network debugging needs this.
What: Open: SYN → SYN-ACK → ACK. Close: FIN → ACK, then FIN → ACK from the other side.
How: TIME_WAIT keeps the socket briefly after close.
ss -tan state time-wait | wc -l
Q66. What is TTL in networking?
Why: It appears in ping output and DNS.
What: In IP, TTL is a hop counter; each router lowers it and drops the packet at 0. In DNS, TTL is how long an answer is cached.
How: Low DNS TTL before a migration lets changes spread quickly.
Q67. What is the difference between a forward proxy and a reverse proxy?
Why: Nginx is often used as a reverse proxy.
What: A forward proxy sits in front of clients. A reverse proxy sits in front of servers.
How: Reverse proxies do load balancing, TLS, caching.
location / { proxy_pass http://app:3000; }
Practice tasks
Easy How do you add a user and give sudo access?
Why: Saying it once with your own words makes it stick.
What to do: Answer this question as if the interviewer just asked it.
- Open a lab VM or container, never production.
- Run or write the example from the answer.
- Read the output line by line.
- Say the answer aloud in under 60 seconds.
Check: Your answer has a reason, a plain meaning and one command.
Easy How do you check the OS version and kernel?
Why: Saying it once with your own words makes it stick.
What to do: Answer this question as if the interviewer just asked it.
- Open a lab VM or container, never production.
- Run or write the example from the answer.
- Read the output line by line.
- Say the answer aloud in under 60 seconds.
Check: Your answer has a reason, a plain meaning and one command.
Medium What does strace do?
Why: Saying it once with your own words makes it stick.
What to do: Answer this question as if the interviewer just asked it.
- Open a lab VM or container, never production.
- Run or write the example from the answer.
- Read the output line by line.
- Say the answer aloud in under 60 seconds.
Check: Your answer has a reason, a plain meaning and one command.
Easy How do you check memory usage?
Why: Saying it once with your own words makes it stick.
What to do: Answer this question as if the interviewer just asked it.
- Open a lab VM or container, never production.
- Run or write the example from the answer.
- Read the output line by line.
- Say the answer aloud in under 60 seconds.
Check: Your answer has a reason, a plain meaning and one command.
Easy How do you check running processes in Linux?
Why: Saying it once with your own words makes it stick.
What to do: Answer this question as if the interviewer just asked it.
- Open a lab VM or container, never production.
- Run or write the example from the answer.
- Read the output line by line.
- Say the answer aloud in under 60 seconds.
Check: Your answer has a reason, a plain meaning and one command.
Easy What is the difference between top, htop and ps?
Why: Saying it once with your own words makes it stick.
What to do: Answer this question as if the interviewer just asked it.
- Open a lab VM or container, never production.
- Run or write the example from the answer.
- Read the output line by line.
- Say the answer aloud in under 60 seconds.
Check: Your answer has a reason, a plain meaning and one command.
Easy How do you schedule a cron job every 15 minutes?
Why: Saying it once with your own words makes it stick.
What to do: Answer this question as if the interviewer just asked it.
- Open a lab VM or container, never production.
- Run or write the example from the answer.
- Read the output line by line.
- Say the answer aloud in under 60 seconds.
Check: Your answer has a reason, a plain meaning and one command.
Easy What is the difference between a hard link and a soft link?
Why: Saying it once with your own words makes it stick.
What to do: Answer this question as if the interviewer just asked it.
- Open a lab VM or container, never production.
- Run or write the example from the answer.
- Read the output line by line.
- Say the answer aloud in under 60 seconds.
Check: Your answer has a reason, a plain meaning and one command.
Homework: try at home
- Pick five questions you find hard.
- Write your own answer for each in three lines.
- Record yourself answering them. Listen once and improve.
Recap
In short
- Answer in order: why, what, how, then one example.
- Show one small command when you can.
- "Asked at" comes from public interview stories.
- Practise aloud; do not memorise word for word.
FAQ
Do I need to learn all 67 questions?
No. Start with the fresher ones. Then add the experienced ones for your level.
Should I memorise these answers?
No. Understand the why, then say it in your own words. Interviewers notice memorised lines.
What if I do not know an answer?
Say so honestly. Then explain how you would find out, step by step.
Are these questions only for one company?
No. "Asked at" shows where people said it was asked. Other companies ask the same things.
How long should an answer be?
About 30 to 60 seconds. Give a reason, a plain meaning and one example.
Is a lab really needed?
Yes. Running the command once makes your answer real and confident.
Interview questions
Practise these five first. Many companies asked them.
- How do you schedule a cron job every 15 minutes? - cron runs commands on a schedule written in five time fields.
- What is the difference between a hard link and a soft link? - A hard link is a second name for the same inode (same data).
- How do you find which process is using the most memory? - Each process shows its memory use in %MEM and RSS.
- What is the difference between grep, awk and sed? - grep finds lines.
- Explain different use cases of grep. - grep prints lines that match a pattern.
Quick quiz
Q1. How do you add a user and give sudo access?
useradd creates the user; adding to the sudo/wheel group gives admin rights.
Q2. What is the difference between a hard link and a soft link?
A hard link is a second name for the same inode (same data).
Q3. How do you check disk usage and free space?
df shows space per file system.
Q4. Which command shows the first 5 lines of a file?
head shows the start, tail shows the end.
Q5. What is the difference between a process and a thread?
A process has its own memory.
Samajla ka?
Revision card
Interview card