Home › Interview questions › Linux
Linux Interview Questions & Answers
78 Linux interview questions in 4 levels — junior to senior, plus 19 production scenarios. Read 3 free answers with real-world analogies.
Free sample answers
What is Linux, and why is it so widely used for servers and DevOps work?
One-liner
Linux is a free, open-source operating system that runs most of the world's servers because it's stable, efficient, and lets you control exactly what runs on the machine.
Real-world analogy
It's like the difference between a fully customizable workshop where you choose every tool on the wall, versus a pre-furnished room where the furniture is fixed. Linux gives you that full control, which is exactly what a server needs.
Detailed explanation
- Linux is open-source, meaning its code is publicly available and free to use, modify, and distribute — this is a big reason cloud providers and companies build their infrastructure on it.
- It's known for being lightweight and stable, often running for months or years without needing a restart, which matters a lot for servers that need to stay up.
- Almost every major cloud provider, container platform, and piece of DevOps tooling (Docker, Kubernetes, most CI/CD systems) is built to run on Linux first.
Scenario
A company evaluating whether to run their servers on Linux or a different operating system finds that nearly all their DevOps tools — Docker, monitoring agents, deployment scripts — are built with Linux as the primary target. Choosing Linux means every tool works smoothly out of the box, instead of fighting compatibility issues on a less common platform.
Best practices
- Get comfortable with the terminal early — most Linux server work happens through the command line, not a graphical interface.
- Don't be intimidated by the many different Linux distributions (Ubuntu, CentOS, Debian) — the core commands and concepts are largely the same across all of them.
- Learn to read documentation and man pages (man <command>) — Linux has excellent built-in documentation for almost everything.
How do you manage and control log files so they don't fill up a server's disk over time?
One-liner
Logrotate automatically compresses, archives, and deletes old log files on a schedule, keeping log growth under control without needing anyone to manually clean things up.
Real-world analogy
It's like a filing cabinet with an automatic assistant who regularly archives old papers into compressed storage boxes, and eventually throws out the oldest boxes once they've been kept long enough — so the cabinet itself never actually overflows.
Detailed explanation
- Logrotate is configured through files in /etc/logrotate.d/, specifying how often to rotate a particular application's logs, how many old versions to keep, and whether to compress them.
- Without log rotation, a chatty application's log file can grow indefinitely, eventually consuming all available disk space and potentially causing the entire server to fail in unrelated ways once the disk is full.
- Most common Linux software already comes with a sensible default logrotate configuration, but custom applications you build yourself need their own configuration added explicitly, or their logs won't be managed at all.
Scenario
A server unexpectedly runs out of disk space, and investigation traces it to a custom application's log file that had been growing, completely unmanaged, for months, since nobody had set up log rotation for it specifically. Adding a logrotate configuration for that application — rotating daily and keeping only the last two weeks of logs — permanently solves the unbounded growth.
Best practices
- Set up a logrotate configuration for any custom application you deploy that writes its own log files — don't assume rotation happens automatically.
- Choose a retention period based on how far back you'd realistically need to look during an investigation, rather than keeping everything forever by default.
- Periodically check df -h on servers with heavy logging, especially early on, to confirm your rotation settings are actually working as expected.
You notice a growing number of zombie or defunct processes on a server. What causes this, and is it actually a problem?
One-liner
A zombie process is one that has already finished, but whose parent process hasn't yet properly acknowledged its exit status — a few zombies are usually harmless, but a large, steadily growing number points to a bug in the parent application that needs fixing.
Real-world analogy
It's like an employee who has already finished their assigned task and formally clocked out, but whose manager hasn't yet actually signed off on and filed the completed paperwork — the employee is technically already gone, but a small, lingering administrative trace of them still remains on record until that final sign-off happens.
Detailed explanation
- When a process finishes, it becomes a 'zombie' briefly until its parent process calls a specific function to properly acknowledge its exit status and officially clean up its remaining process table entry.
- A small number of very short-lived zombies is completely normal and expected, since this cleanup step usually happens quickly — but a large, growing number specifically indicates the parent process isn't ever properly cleaning up after its own child processes.
- Since zombie processes are already finished, they don't actually consume real CPU or memory resources beyond a very small amount of process table space — but a large-enough number of them can still eventually exhaust the finite total limit on process table entries.
Scenario
A monitoring check flags a steadily growing count of zombie processes on a server over several days. Investigation traces them all back to one particular custom application that spawns short-lived child processes for a specific task, but has a bug that never properly acknowledges when they finish. Fixing the bug in that application's parent process, so it properly cleans up after its own child processes, stops the zombies from accumulating any further.
Best practices
- Treat a small number of very short-lived zombies as completely normal — they're an expected, brief, and temporary part of ordinary process lifecycle behavior.
- Investigate a steadily growing zombie count as a genuine bug in a specific parent application, rather than trying to directly 'fix' or otherwise remove the zombie processes themselves, since they can't actually be killed directly.
- Use ps aux and look specifically at the parent process ID (PPID) column to help identify exactly which parent application is actually responsible for the zombies you're seeing.
A preview of the 78 questions in the Linux guide
Junior (21)
- What is Linux, and why is it so widely used for servers and DevOps work?
- What is the Linux file system hierarchy, and what do folders like /etc, /var, and /home actually store?
- What is a shell, and what's the difference between a shell and a terminal?
- How do Linux file permissions work, and what do the letters r, w, and x actually mean?
+ 17 more Junior questions, with full answers, in the guide.
Mid-level (20)
- How does systemd manage services, and how do you check why a service failed to start?
- How do cron jobs work, and what are some common reasons a cron job silently doesn't run?
- What are setuid, setgid, and the sticky bit, and when would you actually encounter them?
- What does process priority mean, and how do nice and renice let you control it?
+ 16 more Mid-level questions, with full answers, in the guide.
Senior (18)
- How would you approach kernel tuning (sysctl settings) for a production server under heavy load?
- How would you design a centralized logging strategy for a large fleet of Linux servers?
- What are Linux namespaces and cgroups, and how do they relate to what makes containers possible?
- How would you decide between filesystems like ext4, XFS, and ZFS for a specific production use case?
+ 14 more Senior questions, with full answers, in the guide.
Scenario (19)
- A server is running out of disk space, and you need to quickly find what's actually taking up all the room. Walk through your approach.
- A server's load average is unusually high, but you're not sure if it's actually a real problem. How do you investigate?
- You notice a growing number of zombie or defunct processes on a server. What causes this, and is it actually a problem?
- A service that was working fine suddenly fails to start after a server reboot. How do you troubleshoot this systematically?
+ 15 more Scenario questions, with full answers, in the guide.
Get the full DevOps / SRE Interview Guide