Linux Interview Questions and Answers for DevOps Roles
Master your upcoming DevOps and SRE interviews with this comprehensive guide to essential Linux interview questions, covering kernel tuning, process management, and troubleshooting.
Linux is the foundational operating system of modern cloud-native architecture, Kubernetes clusters, and CI/CD pipelines. For DevOps and Site Reliability Engineering (SRE) roles, interviewers look beyond basic command-line navigation, probing deep into kernel internals, performance troubleshooting, memory management, and networking.
This comprehensive guide covers the most critical Linux interview questions and answers to help you excel in your next DevOps interview.
1. Process Management and Performance
Q: What is the difference between a process and a thread in Linux?
A process is an independent execution unit with its own dedicated memory space, file descriptors, and system resources. A thread is the smallest unit of execution within a process, sharing the same memory space and file descriptors as other threads in that process, which makes thread creation and context switching significantly faster.
Q: How do load averages work in Linux, and how would you troubleshoot a high load average?
Linux load averages represent the average number of processes in the run queue (either actively running on a CPU or waiting for CPU time) plus processes in uninterrupted disk sleep over 1-, 5-, and 15-minute intervals.
- Check CPU vs I/O Bottlenecks: Use `top` or `htop` to identify whether high load stems from CPU usage (%us, %sy) or disk wait states (%wa).
- Inspect Run Queue: Use `vmstat 1` to analyze running processes (`r`) and blocked processes (`b`).
- Isolate Resource Hogs: Use `ps aux --sort=-%cpu` or `pidstat` to identify specific misbehaving applications.
2. Memory Management and Kernel Tuning
Q: What is Swap memory, and what is the purpose of the `vm.swappiness` parameter?
Swap space is a designated area on a disk used as virtual memory when physical RAM is fully utilized. The `vm.swappiness` kernel parameter (ranging from 0 to 100) controls how aggressively the Linux kernel swaps memory pages out of RAM to disk. A lower value (e.g., 10) prioritizes keeping application memory in RAM to avoid disk I/O latency, while a higher value swaps out inactive pages sooner.
Q: How does the Linux Out-Of-Memory (OOM) Killer operate?
When the Linux kernel exhausts both physical RAM and swap space and cannot allocate more memory, the OOM Killer steps in to protect system stability by terminating one or more resource-intensive processes. The kernel calculates an `oom_score` for each process based on its memory consumption and adjusts this via `oom_score_adj` to determine which process to sacrifice.
3. Networking and Socket Troubleshooting
Q: How do you troubleshoot network connectivity issues between two hosts in Linux?
Systematic network troubleshooting follows a layered approach:
- Layer 3 / ICMP: Use `ping` to check basic host reachability.
- Port and Service Availability: Use `nc -zv
` or `telnet` to verify if a TCP port is open and listening. - Route Tracing: Use `traceroute` or `mtr` to inspect intermediate network hops and packet loss.
- Packet Inspection: Use `tcpdump` or `ss -tuln` to capture network traffic and inspect active socket connections.
4. Storage and Filesystem Management
Q: What is LVM (Logical Volume Manager), and why is it preferred over standard partitions?
LVM provides a high-level abstraction layer over physical storage devices, allowing system administrators to pool multiple disks into Volume Groups (VGs) and dynamically resize Logical Volumes (LVs) online without downtime or unmounting filesystems.
Q: What are inodes, and how would you troubleshoot an 'No space left on device' error when disk space is available?
An inode is a data structure in a Unix-style filesystem that stores metadata about a file (such as permissions, ownership, and size), excluding its actual data content or filename. If a filesystem creates millions of tiny files (such as cache files or log chunks), it can exhaust all available inodes even if physical disk capacity remains high. You can check inode usage using `df -i`.
Conclusion
A strong grasp of Linux internals, kernel parameters, process behavior, and debugging utilities is non-negotiable for DevOps professionals. Mastering these concepts ensures you can maintain high availability and troubleshoot complex production incidents with confidence.