Linux Operating Systems & Kernel Internals Master Interview Bank
Linux process management (fork, execve, zombie, orphan), virtual memory & page tables, VFS (Virtual File System), system calls, and signals.
Curriculum Roadmap & Learning Path
3 StagesPart 1: Basic & Foundational Concepts (Junior / Entry-Level)
10 QuestionsWhat is the difference between User Space and Kernel Space in Linux?
The CPU runs in different privilege rings to protect the system: Kernel Space (Ring 0): Unrestricted, privileged execution mode • User Space (Ring 3): Restricted, unprivileged mode where standard user applications (Node.js, Nginx, Python) run.
What is the difference between a Process and a Thread in Linux?
Process: An independent instance of an executing program with its own isolated virtual address space, file descriptors, and environment variables • Thread: An execution unit inside a process • Linux Kernel Perspective (taskstruct): To the Linux kernel, both processes and threads are represented identically as tasks (taskstruct).
What is PID 1 (`init` / `systemd`) and what is its role?
PID 1 is the very first process launched by the Linux kernel during boot: The ancestor/parent of all other processes in the operating system • Responsibilities • Bootstraps system services, mounts filesystems, and configures networking.
What are Zombie Processes and Orphan Processes?
Orphan Process: A child process whose parent died while the child was still running • Outcome: Automatically adopted by PID 1 (init/systemd), which monitors it until termination • Zombie Process (): A child process that has finished execution (exit()), but its parent has not yet read its exit status via wait() / waitpid().
What are the common Linux Process States in `ps` and `top`?
R (Running / Runnable): Actively executing on a CPU core or sitting in the run queue ready to execute • S (Interruptible Sleep): Waiting for an event (I/O, timer, socket) • D (Uninterruptible Sleep - Disk Sleep): Waiting for hardware/disk I/O • T (Stopped / Traced): Paused by a signal (SIGSTOP, Ctrl+Z) or debugger.
What are the essential Linux Signals (`SIGTERM`, `SIGKILL`, `SIGINT`, `SIGHUP`)?
Signals are asynchronous notifications sent to a process by the kernel or user: SIGTERM (15): Graceful termination request • SIGKILL (9): Forceful kill • SIGINT (2): Interrupt sent from terminal via Ctrl+C • SIGHUP (1): Hangup.
What is an Inode in Linux File Systems?
An inode (Index Node) is a fixed-size data structure storing all metadata about a file except its filename and actual content: Stores: File size, owner user/group ID, permissions, timestamps (atime, mtime, ctime), and disk block pointers where data lives.
What is the difference between a Hard Link and a Soft (Symbolic) Link?
Hard Link (ln file link): Creates an additional directory entry pointing to the exact same Inode number • Shares the same disk blocks • If you delete the original file, the data is still fully accessible via the hard link! • Cannot span across different filesystems/disks, and cannot link directories.
What are Linux File Permissions (`chmod`, `chown`, and Octal Notation)?
Permissions are evaluated for User (owner), Group, and Others: Read (r = 4), Write (w = 2), Execute (x = 1) • chmod 755 script.sh • User: 4+2+1 = 7 (rwx - full access) • Group: 4+0+1 = 5 (r-x - read & execute).
What are SUID, SGID, and the Sticky Bit?
Special permission bits extending standard Unix permissions: SUID (chmod 4755 / u+s): Executable runs with the permissions of the file owner, not the executing user (e.g. /usr/bin/passwd runs as root so.
Part 2: Core Architecture & Implementation (Mid-Level)
10 QuestionsHow does Virtual Memory and Page Tables work in Linux?
Processes never access physical RAM addresses directly; they operate in an isolated Virtual Address Space: Memory Management Unit (MMU): Hardware chip in the CPU that translates virtual addresses to physical RAM addresses.
What are Minor Page Faults vs Major Page Faults?
When a process accesses a virtual memory address that is not currently mapped in physical RAM: Minor Page Fault (Soft): The page is already resident in physical RAM (e.g. shared library page loaded by another process, or allocated memory.
What is the Linux Out-Of-Memory (OOM) Killer and how does it choose victims?
Linux employs Memory Overcommit: it allows processes to allocate more virtual memory than physical RAM exists, betting that processes will not use all allocated RAM simultaneously: When physical RAM and swap are completely exhausted, the kernel invokes the OOM Killer to prevent an OS kernel panic.
How does the Completely Fair Scheduler (CFS) allocate CPU time?
CFS is the default Linux CPU scheduler for standard processes: Models an "ideal multi-tasking CPU" where every process gets a fair slice of CPU time • Uses a Red-Black Tree ordered by vruntime (Virtual Runtime): the amount of CPU execution time the process has received.
What are the Inter-Process Communication (IPC) mechanisms in Linux?
Ways independent processes communicate: Pipes & Named Pipes (FIFOs): Unidirectional byte streams between related () or unrelated processes • UNIX Domain Sockets (AF_UNIX): Bidirectional streaming or datagram communication on the same machine • Shared Memory (shmget / mmap): Fastest IPC!
What is the Virtual File System (VFS) and what are `/proc` and `/sys`?
VFS: A kernel abstraction layer that defines standard file interfaces (open, read, write, close), allowing Linux to interact uniformly with • /proc (Process Information Pseudo-filesystem): Exists strictly in RAM • /sys (Sysfs): Exposes hardware device trees, kernel modules, and driver settings.
What are File Descriptors and the "Too many open files" error?
Every open file, network socket, pipe, or device in Linux is represented by a non-negative integer called a File Descriptor (FD): Standard FDs: 0 (stdin), 1 (stdout), 2 (stderr) • ulimit -n: The maximum number of open file descriptors allowed per process (default often 1024).
What is the difference between Blocking, Non-Blocking, and I/O Multiplexing?
Blocking I/O: Thread calls read() and halts completely until data arrives • Non-Blocking I/O: Calls return immediately with EAGAIN / EWOULDBLOCK if no data is ready • I/O Multiplexing (epoll): A single thread registers 10,000 sockets with the kernel.
How does `epoll` differ from `select` and `poll`?
The foundation of high-concurrency web servers (Nginx, Node.js, Redis): select / poll (Ancient - O(N)): Every time an event occurs, the kernel returns the entire list of sockets • epoll (Modern Linux - O(1)) • Uses an internal Red-Black tree to monitor file descriptors.
How do Systemd Units and Service Management work?
Systemd manages system initialization, background daemons, and cgroups: Unit Files (/etc/systemd/system/myapp.service) • [Unit]: Metadata, dependencies (After=network.target) • [Service]: Execution command (ExecStart), restart policy (Restart=always), sandboxing.
Part 3: Advanced Internals, Scale & Production Patterns (Senior / Lead)
30 QuestionsWhat are Linux Namespaces and what are the 7 core Namespace types?
Namespaces are the foundational isolation mechanism of Docker containers: A namespace wraps a global system resource in an abstraction, making processes inside believe they have their own dedicated copy • PID Namespace: Process isolation (container process sees itself as PID 1).
What are Control Groups (Cgroups v1 vs v2) and how do they enforce resource limits?
While Namespaces control what a process can see, Cgroups control how much resources a process can consume: Limits Enforced • Memory (memory.max): Hard RAM limit; exceeding it triggers the OOM killer on the container • CPU (cpu.max): Enforces CFS bandwidth quotas (e.g. 2 cores = 200000 100000).
What is `io_uring` and how does it revolutionize Linux Asynchronous I/O?
iouring is a modern Linux kernel interface (introduced by Jens Axboe in Linux 5.1): Traditional Syscall Overhead: Calling read() or epollwait() requires a CPU context switch from user space to kernel space, incurring • io_uring Design: Uses two lockless ring buffers in shared memory.
How do you troubleshoot system performance using `vmstat`, `iostat`, and `sar`?
vmstat 1: High-level overview of processes (r, b), memory, swap (si, so), and CPU (us, sy, id, wa, st) • High b (blocked processes) + high wa (I/O wait) indicates disk bottlenecks! • si/so > 0 indicates active memory swapping (system running out of RAM).
How do you trace live system calls using `strace`?
strace intercepts and records all system calls executed by a process and the signals received.
What is `lsof` and how do you find open ports, deleted files, and active connections?
"List Open Files" (lsof) displays all active file descriptors across the OS: lsof -i :8080: Finds which process is listening on or connected to port 8080 • lsof -u appuser: Lists all files opened by a specific user • Find Deleted Files Holding Disk Space.
What is Swappiness (`vm.swappiness`) and how does it balance RAM vs Disk?
Controls the kernel's aggressiveness in moving anonymous memory pages to swap space vs reclaiming file system cache (0 to 100, default 60): vm.swappiness = 0: Kernel will only swap to prevent Out-Of-Memory conditions • vm.swappiness = 100: Aggressively swaps anonymous memory to disk to maximize file system cache.
What are HugePages and why do databases use them?
Standard Linux memory pages are 4 KB: A server with 256 GB of RAM requires millions of page table entries, filling the CPU's Translation Lookaside Buffer (TLB) cache and causing • HugePages: Allocates memory in 2 MB or 1 GB chunks • Dramatically reduces the number of page table entries by 500x.
How does Network Packet Processing work in the Linux Kernel (sk_buff, Netfilter, eBPF)?
NIC receives packet, DMA-transfers bytes to host RAM, triggers a hardware interrupt • Kernel processes packet via NAPI polling loop, wraps raw bytes in an sk_buff (Socket Buffer) • Packet traverses the Netfilter architecture (iptables / nftables chains: PREROUTING, INPUT, FORWARD, OUTPUT, POSTROUTING).
What is the difference between TCP SYN Flood attacks and SYN Cookies?
TCP SYN Flood: Attacker sends millions of SYN packets with spoofed source IPs, ignoring the SYN-ACK • SYN Cookies (tcp_syncookies = 1): When the backlog queue fills up, the server stops storing connection state in memory • Encodes connection state into the Initial Sequence Number (ISN) of the SYN-ACK packet.
What is the Core Dump file and how do you analyze it using GDB?
A Core Dump is a memory snapshot of a process captured at the exact moment it crashed (e.g. SIGSEGV segmentation fault): Enabled via ulimit -c unlimited • Debugging with GDB.
What is `chroot` and what are its security limitations compared to Containers?
chroot changes the apparent root directory (/) for the current running process and its children: Limitation (Not a Sandbox): chroot does not isolate processes, network interfaces, or user IDs • A root user inside a chroot jail can easily escape by creating a nested chroot or using open file descriptors.
What is Seccomp (Secure Computing Mode)?
A Linux kernel security feature that restricts the system calls a process can make: Default Profile (Docker): Blocks over 40 dangerous syscalls (e.g. reboot, ptrace, clone without namespaces, sys_chroot).
What is the difference between Ext4 and XFS filesystems?
Ext4 (Fourth Extended Filesystem): Universal general-purpose Linux filesystem • XFS: High-performance 64-bit journaling filesystem created by SGI • Exceptional parallel I/O throughput and scalability for massive multi-terabyte files and multi-threaded databases • Default filesystem in RHEL / CentOS.
When should you use Linux Performance Profiling with `perf` and Flame Graphs?
When CPU usage is pinned at 100% and you need to know which exact code functions are responsible: perf record -F 99 -p PID -g -- sleep 30: Samples CPU stack traces at 99Hz • Generate Brendan Gregg Flame Graphs • Horizontal axis: Shows the proportion of CPU time spent in each function • Vertical axis: Shows call stack depth.
Linux Boot Sequence: From UEFI/BIOS, GRUB2, Kernel Initialization, to systemd PID 1.
Power-On & POST / UEFI: Hardware self-test • GRUB2 Bootloader: Presents the OS menu, loads the selected kernel image (vmlinuz) and the temporary initial RAM filesystem (initramfs) into memory • Kernel Initialization: Decompresses itself, initializes CPU registers, page tables, interrupts, and drivers from initramfs, then mounts the real.
HugePages and Transparent HugePages (THP): How they optimize database performance and why Redis advises disabling THP.
Standard x86-64 page size is 4 KB. For applications managing 64 GB+ RAM (databases), navigating billions of 4 KB pages overloads the CPU TLB (Translation Lookaside Buffer) cache: HugePages (2 MB / 1 GB): Reduces the number of page table entries by 500x, boosting database memory lookup throughput.
Linux Cgroups v1 vs Cgroups v2: Architecture differences and modern unified hierarchy.
Cgroups v1 (Legacy): Orthogonal multi-hierarchy design where each resource (CPU, Memory, BlkIO) had its own independent tree structure • Cgroups v2 (Unified Hierarchy): Single unified tree structure rooted at /sys/fs/cgroup • Single Root of Control: A process belongs to exactly one cgroup node.
Linux Epoll vs Select/Poll: How Event-Driven I/O enables the C10K and C10M problem solutions (Nginx, Node.js).
Handling 10,000+ concurrent network connections: select() / poll() (O(N) Complexity): The application passes an array of 10,000 file descriptors to the kernel on every loop • epoll() (O(1) Complexity): The application registers sockets once in kernel memory (epollcreate, epollctl).
Linux Swap Space, Swappiness (`vm.swappiness`), and ZRAM: When and how to configure swapping.
Swap: Disk space used when physical RAM is exhausted, paging inactive anonymous memory to disk • vm.swappiness (0 - 100): Controls the kernel's balance between reclaiming page cache (file buffers) vs swapping anonymous memory • swappiness = 60: Default desktop behavior.
Linux IPC (Inter-Process Communication): Pipes, Unix Domain Sockets, Shared Memory, and Message Queues.
IPC Mechanism Speed / Latency Persistence Use Case.
Linux Kernel Capabilities: Least privilege without full root access.
Traditionally, a process was either unprivileged (UID != 0) or all-powerful root (UID == 0). Linux Capabilities divide root privileges into over 40 distinct permissions: CAPNETBINDSERVICE: Allows binding to privileged network ports (< 1024) without running as root (e.g. setcap 'capnetbindservice=+ep' /usr/sbin/nginx).
Linux Network Tuning for High-Concurrency Web Servers (`sysctl.conf`).
Production web servers handling high QPS require kernel network stack tuning.
Understanding Linux I/O Schedulers: `mq-deadline`, `bfq`, `kyber`, and `none` (NVMe bypass).
I/O schedulers reorder and batch block storage read/write requests to optimize disk throughput: none: Bypasses the scheduler entirely • mq-deadline: Guarantees a deadline for every I/O request, preventing starvation • bfq (Budget Fair Queueing): Allocates bandwidth fractions to processes.
Systemd Units and Service Management: Anatomy of a `.service` file, restart policies, and watchdog integration.
A robust production systemd service definition.
Linux Inodes, Hard Links vs Symbolic Links, and recovering from Inode Exhaustion.
Inode (Index Node): A data structure storing metadata about a file (permissions, owner, size, timestamp, pointers to disk data blocks), but not • Hard Link: A new directory entry pointing to the same inode number • Symbolic Link (Symlink): A pointer file containing the string path to another file.
Linux Kernel Panic: Causes, debugging via `kdump` / `crash` utility, and reading kernel stack traces.
A Kernel Panic is an unrecoverable fatal error where the kernel cannot safely continue executing without risking data corruption (e.g. memory hardware fault, null pointer in kernel driver, corrupted root filesystem).: kdump Mechanism: Upon panic, the kernel uses kexec to boot into a minimal secondary recovery kernel...
Linux Memory Allocators: Glibc `malloc`, `jemalloc`, and `tcmalloc` in high-concurrency applications.
Standard glibc malloc uses global mutex locks or a limited number of memory arenas. In applications with 64+ concurrent threads (e.g. MySQL, Redis, Java apps), threads spend excessive CPU time waiting on lock contention during memory allocations.: jemalloc (FreeBSD / Meta): Partitions memory into thread-specific arenas...
Understanding `strace`, `ltrace`, and `ftrace`: Tracing system calls, dynamic library calls, and kernel events.
strace -p PID -e trace=network,file -tt -T: Intercepts and records system calls made between user-space processes and the Linux kernel, printing • ltrace: Intercepts dynamic library calls (e.g. calls to libc.so, libssl.so).
Linux PAM (Pluggable Authentication Modules): How SSH, Sudo, and system authentication pipelines work.
PAM decouples system applications (sshd, sudo, login) from specific authentication technologies (local /etc/shadow, LDAP, Kerberos, Duo MFA, YubiKey FIDO2).: Configuration files reside in /etc/pam.d/ (/etc/pam.d/sshd, /etc/pam.d/sudo) • Four Management Modules • auth: Verifies user identity (password, MFA token).