Interview Q&A · questions with model answers
Linux Interview Questions
Part of the study plan for: DevOps Engineer · Site Reliability Engineer (SRE)
Ordered by how often they're asked. Most-asked answers are free to read in full; members see every answer and can rate their confidence on each.
-
Most asked A Linux server has high CPU usage. How do you find the cause?
Confirm what kind of CPU time it is, then find the process and, if needed, the code path. top or htop shows the busiest processes and the split between user (us), system (sy), I/O wait (wa) and…
-
Most asked What do top, htop, vmstat, iostat, ss and lsof each tell you?
top/htop show live per-process CPU and memory; vmstat shows system-wide CPU, memory, swap and run queue over time; iostat -x shows per-disk throughput, latency and utilisation; ss lists sockets and…
-
Most asked Write a script that alerts when disk usage passes a threshold.
Read usage per filesystem with df, compare with a threshold, and send an alert (log, email, Slack webhook) for each filesystem over it. Exit non-zero when something is over, so cron, systemd or a…
-
How do you troubleshoot DNS resolution and network connectivity on Linux?
Work up the layers: is the interface up with an address and route, can you reach the IP, does the name resolve (and with which resolver), is the port open, and does TLS/HTTP work? Separate DNS…
-
A server keeps running out of memory and the kernel kills processes. How do you investigate?
Confirm it's the OOM killer (dmesg -T | grep -i oom, journalctl -k), see which process was killed and which was using memory, then decide whether it's a leak, a genuine increase in load, or limits…
-
The disk is full, but du shows far less usage than df. What's going on?
A process still holds open a file that was deleted (often a log rotated without the program reopening it). The space isn't freed until the file is closed, so df counts it but du can't see it. lsof…
-
How do systemd units work, and how do you debug a service that won't start?
systemd starts services from unit files that declare the command, user, dependencies, restart policy and environment. systemctl status and journalctl -u name show why a unit failed; most failures…
-
Explain Linux file permissions, ownership and the special bits.
Each file has an owner, a group and read/write/execute bits for owner, group and others (for example 0640). The special bits are setuid (run as the file's owner), setgid (run as the group, or new…
-
What is load average, and how is it different from CPU utilisation?
Load average is the average number of tasks running or waiting to run (and, on Linux, in uninterruptible I/O sleep) over 1, 5 and 15 minutes. CPU utilisation is the percentage of time the CPUs were…
-
How do you find what's listening on a port and which process owns it?
ss -tlnp lists listening TCP sockets with the owning process (run with sudo to see all processes); sudo lsof -i :8080 shows which process has a given port open. Check the bind address too:…
-
How do you search logs effectively with journalctl and standard tools?
Use journalctl filters (unit, time, priority, boot) to narrow the journal, and grep, awk and sort | uniq -c on text logs to count and group errors. For anything across servers, use the central log…
-
What happens when a Linux system boots?
Firmware (UEFI or BIOS) loads a bootloader (GRUB), which loads the kernel and an initramfs. The kernel initialises hardware, the initramfs finds and mounts the real root filesystem, then the kernel…
-
What is the difference between kill, kill -9 and a graceful shutdown?
kill PID sends SIGTERM, which a program can catch to finish work and exit cleanly. kill -9 sends SIGKILL, which can't be caught: the process stops immediately, losing in-flight work and leaving…