Linux Interview Questions

Dan Lee's profile image
Dan LeeData & AI Lead
Last update
Linux Interview Questions

Linux interviews for SRE, DevOps, backend and data engineering roles are mostly troubleshooting. You get a symptom (a full disk that du cannot explain, a load average of 16 with idle CPUs, a container that ignores docker stop) and you are expected to explain the mechanism and the next command to run.

Candidates slip on a predictable set of details: the difference between TIME_WAIT and CLOSE_WAIT, what load average actually counts, why RSS overstates memory, why PID 1 ignores SIGTERM, and how a deleted file can still fill a disk. Each one is a single fact about the kernel that turns a guess into a diagnosis.

This page has 30 practice questions in five areas: processes and signals, files and disks, memory and performance, networking and DNS, and shell, systemd and containers. Answers cite real defaults and commands, with shell snippets you can run on a Linux host.

Intermediate30 questions

Linux Interview Questions

Practice Linux interview questions on processes, signals, file systems, memory, load, TCP, DNS, systemd and containers, with worked answers and commands.

Site Reliability EngineerDevOps EngineerBackend EngineerPlatform EngineerData Engineer

Processes and Signals

Process questions are the opening move in most Linux rounds because they test whether you understand what the kernel is doing beneath every service you run. Expect graceful shutdown, zombies, PID 1 in containers and processes that ignore kill -9.

One idea covers most of them: a process is created by fork(), transformed by execve(), and must be reaped by its parent with wait(). Signals are the only way to interrupt one from outside, and each signal has a default action that a process may or may not override.

Processes and Signals

During a deploy, kill <pid> leaves the old worker running for almost a minute, so someone changes the script to kill -9. Explain the difference between SIGTERM and SIGKILL and write the stop logic you would ship.

EasyProcesses and Signals

Sample Answer

kill sends SIGTERM (15) by default. A process can catch it, stop accepting work, finish in-flight requests, flush buffers and exit cleanly. SIGKILL (9) cannot be caught, blocked or ignored: the kernel ends the process immediately, so nothing is flushed, temp and lock files stay behind, and clients see reset connections. The standard pattern is SIGTERM, wait with a deadline, then SIGKILL as a last resort. systemd does exactly this (TimeoutStopSec defaults to 90 s), docker stop waits 10 s, and Kubernetes waits terminationGracePeriodSeconds (30 s by default). If a worker needs a minute to drain, fix its shutdown handler or raise the grace period rather than skipping straight to SIGKILL.

Bash
1kill -TERM "$pid"
2for _ in $(seq 30); do
3  kill -0 "$pid" 2>/dev/null || exit 0   # process is gone: clean stop
4  sleep 1
5done
6echo "still running after 30 s, sending SIGKILL" >&2
7kill -KILL "$pid"
Learn this in the Site Reliability Engineering Interview course

Files, Disks and Permissions

"The disk is full" is one of the most common pages an on-call engineer gets, and interviewers love it because the obvious answer is usually wrong. These questions cover inodes, links, deleted files that still hold space, permissions and reading disk latency.

The key idea is that a file name is just a directory entry pointing at an inode. Space is freed only when no names and no open descriptors refer to the inode, and permissions apply to every directory along the path.

Files, Disks and Permissions

Explain the difference between a hard link and a symbolic link in terms of inodes. Which one survives deleting the original file, and which one can point to another filesystem?

EasyFiles, Disks and Permissions

Sample Answer

A directory entry maps a name to an inode number. The inode holds metadata and the location of the data, but not the name. A hard link is a second name for the same inode, so the link count goes up. rm calls unlink(), which removes one name; the data is freed only when the count reaches zero and no process still has the file open. So the hard link survives deleting the original. Hard links cannot cross filesystems, because inode numbers are only unique within one, and cannot point to directories. A symbolic link is a separate inode whose content is a path. It can cross filesystems and point to directories, but it dangles when the target is removed or renamed.

Bash
1echo data > a.txt
2ln a.txt hard.txt        # same inode, link count becomes 2
3ln -s a.txt soft.txt     # new inode that stores the path "a.txt"
4ls -li a.txt hard.txt soft.txt
5rm a.txt
6cat hard.txt             # data
7cat soft.txt             # No such file or directory
Learn this in the Site Reliability Engineering Interview course

Memory, CPU and Performance Triage

Troubleshooting rounds hand you tool output and ask what it means. You are expected to read free, ps, vmstat, load average and OOM messages correctly, and to know which tool answers which question without slowing the host down.

The most useful habit is to separate busy from blocked. A busy system has runnable tasks and high CPU; a blocked one has tasks waiting on I/O, locks or memory. Load average, vmstat and pressure stall information all tell you which one you are looking at.

Memory, CPU and Performance Triage

free -h on a 32 GiB server shows only 0.5 GiB free and 24 GiB under buff/cache. A teammate wants to add RAM. What do you tell them, and what would real memory pressure look like?

EasyMemory, CPU and Performance Triage

Sample Answer

Linux uses otherwise idle memory as page cache for file data, because empty RAM does nothing useful. Clean cached pages are dropped the moment an application needs memory, so a low free column is normal on a healthy server. Read the available column instead. It is the kernel's estimate (MemAvailable) of memory that can be handed to new allocations without swapping, and it includes reclaimable cache. Real pressure shows up as low available, continuous swap activity in the si and so columns of vmstat 1, rising major page faults, non-zero stall times in /proc/pressure/memory, and OOM kills in dmesg. Used swap on its own is not a problem; steady swapping in and out is. Dropping caches with drop_caches fixes nothing and makes the next reads slower.

Learn this in the Site Reliability Engineering Interview course

Networking and DNS

Most production incidents that are not code bugs are network or DNS problems, so SRE and backend interviews spend real time here: socket states, port exhaustion, name resolution and firewalls, usually framed as "connections are failing, find out why".

Learn the TCP state machine well enough to know which side owns each state. TIME_WAIT belongs to whoever closed first and expires on its own. CLOSE_WAIT belongs to whoever has not yet called close() and never expires, so it always points at an application.

Networking and DNS

Your service fails to start with bind: Address already in use on port 8080. Find what holds the port. Then explain why the service can be listening and still refuse connections from other hosts.

EasyNetworking and DNS

Sample Answer

ss -ltnp lists listening TCP sockets with numeric ports and the owning process; run it as root to see processes of other users. Filter with 'sport = :8080'. The holder is often a previous instance still shutting down, or a stray copy started by hand. The second problem is the bind address. A server bound to 127.0.0.1:8080 accepts only connections that originate on the same host. Binding to 0.0.0.0:8080 (or [::]:8080 for IPv6) accepts on every interface. This bites most often in containers, where an app bound to loopback inside the container cannot be reached through the published port. If the address is right and remote clients still fail, check the firewall next.

Bash
sudo ss -ltnp 'sport = :8080'
# LISTEN 0 4096 127.0.0.1:8080 0.0.0.0:* users:(("api",pid=4121,fd=7))
# 127.0.0.1 means local clients only; bind 0.0.0.0 or [::] for remote clients
Learn this in the Site Reliability Engineering Interview course

Shell, systemd and Containers

Day-to-day Linux work is pipelines, service units and containers. Interviewers check that you can process logs with standard tools, run services under systemd without crash loops, and explain containers as kernel features rather than magic.

The underlying idea is composition. Small tools joined by pipes, units that systemd supervises, and containers built from namespaces plus cgroups all behave predictably once you know the rules of each part, and fail in confusing ways when you do not.

Shell, systemd and Containers

Given an nginx access log in the default combined format, print the 10 client IPs with the most 5xx responses. Then explain why uniq -c needs sort in front of it.

EasyShell, systemd and Containers

Sample Answer

In the combined format, whitespace splitting puts the client IP in $1 and the status code in $9, because the quoted request line splits into three fields. Filter on a 5xx status, print the IP, then count. uniq collapses only adjacent duplicate lines, so unsorted input gives wrong counts. sort | uniq -c | sort -rn is the standard count-and-rank idiom. The second form counts in one awk pass with an associative array and only sorts the distinct IPs, which is faster on large files. LC_ALL=C sort also speeds up sorting a lot. The trap: a malformed request line with extra spaces shifts the fields. For production analysis, log JSON or split on the quote character.

Bash
1awk '$9 ~ /^5[0-9][0-9]$/ {print $1}' access.log | sort | uniq -c | sort -rn | head -10
2
3# one pass, sort only the distinct IPs
4awk '$9 ~ /^5/ {n[$1]++} END {for (ip in n) print n[ip], ip}' access.log | sort -rn | head -10
Learn this in the Site Reliability Engineering Interview course

How to Prepare for Linux Interviews

Practice on a real Linux box, not a laptop shell

macOS and BSD tools differ from Linux in ps, sed, xargs and /proc, which does not exist there. Spin up a small VM or container and reproduce each symptom on this page: a zombie, a deleted-but-open file, a full inode table. Processes and signals and Files and descriptors walk through these step by step.

Learn to read tool output cold

Interviewers paste output from vmstat, iostat, free or ss and ask what is wrong. Practice naming every column you rely on and the number that would worry you. CPU and load, Memory and Disk and I/O use real output throughout.

Know the TCP state machine and the DNS path

Draw the TCP close sequence from memory and say which side holds each state and for how long. Then trace a name lookup from getaddrinfo to the nameserver. TCP in production and DNS and load balancing cover both with production failure cases.

Rehearse a troubleshooting method out loud

In a live round, a structured approach beats a memorized command list. State the symptom, form a hypothesis, pick the command that tests it, and say what you ruled out. The troubleshooting round teaches the method, and Lab: the website is down lets you practice it on a broken system.

Get fast at text processing

Many loops include a practical scripting task such as parsing a log, counting errors per host or finding the slowest endpoints. Be fluent with awk, sort, uniq, xargs and grep, and know when to switch to Python. Log parsing at scale and The coding round have timed exercises.

How Ready Are You for Linux Interviews?

1 / 6
Disks

df says /var is 100% full but du reports 30 GB less. What is the most likely cause?

Frequently Asked Questions

What Linux topics come up most in SRE and DevOps interviews?

Expect processes and signals, file systems and full disks, memory and the OOM killer, load average and CPU, TCP connection states, DNS resolution, and systemd services. Container roles add namespaces and cgroups. Most of it is asked as troubleshooting: you are given a symptom or a block of tool output and asked what is happening and what you would run next, so practice explaining the mechanism, not just naming the command.

Do data engineers and backend engineers get Linux questions?

Yes, though usually lighter than SRE loops. Backend interviews often include connection problems, file descriptor limits, memory usage of services and reading logs from the command line. Data engineers get questions about disks filling up, processes killed by the OOM killer, long-running jobs that die when an SSH session closes, and text processing with awk, sort and xargs on large files.

How deep do I need to know Linux internals?

For most roles you need the kernel concepts that explain symptoms: inodes, file descriptors, process states, page cache, virtual versus resident memory, the TCP state machine, namespaces and cgroups. You do not need to read kernel source. Senior SRE and platform roles go further into performance tools such as perf, pressure stall information, cgroup v2 controllers and how the scheduler enforces CPU limits.

Which Linux commands should I know by heart?

Be fluent with ps, top, kill, df, du, lsof, free, vmstat, iostat, ss, ip, dig, curl, tcpdump, strace, journalctl, systemctl, and the text tools grep, awk, sed, sort, uniq and xargs. More important than flags is knowing which command answers which question and how to read its output, since interviewers usually paste output and ask you to interpret it.

How long does it take to prepare for a Linux interview?

If you already operate Linux servers, two to three weeks of focused practice usually covers it: one area from this page every few days, plus reproducing each failure on a VM. Coming mainly from application development, plan four to six weeks, because reading vmstat, iostat and ss output fluently takes repetition on a real system rather than reading about it.

Can I practice Linux interview questions on a Mac?

Only partly. macOS shares the shell and many command names, but ps, sed, xargs and top behave differently, and /proc, systemd, cgroups and most of the networking tools are missing. Use a Linux VM or a container for practice, and use a full VM for anything involving systemd, the OOM killer or kernel settings, since containers share the host kernel.

Dan Lee's profile image

Written by

Dan Lee

Data & AI Lead

Dan is a seasoned data scientist and ML coach with 10+ years of experience at Google, PayPal, and startups. He has helped candidates land top-paying roles and offers personalized guidance to accelerate your data career.

Connect on LinkedIn