OS Notes
Comprehensive Linux interview questions and answers covering commands, file systems, process management, permissions, networking, and shell scripting for technical interviews.
Introduction
Linux knowledge is tested in almost every systems-related technical interview — whether you are applying for a DevOps role, backend developer position, or system administrator job. Interviewers expect you to demonstrate practical command-line fluency, understanding of Linux internals, and the ability to troubleshoot real-world problems. This page covers frequently asked questions organized from basic to advanced, with clear answers that demonstrate depth of understanding.
Basic Linux Questions
Q1: What is the difference between Linux and Unix?
Answer: Unix is the original operating system developed at Bell Labs in the 1970s. Linux is a Unix-like operating system created by Linus Torvalds in 1991. Key differences: Unix is proprietary (owned by various vendors like IBM AIX, Sun Solaris), while Linux is open-source under the GPL license. Linux was written from scratch — it does not contain Unix code but follows the same design philosophy (everything is a file, small composable tools, plain text configuration). Today, Linux dominates servers, embedded systems, and mobile (Android), while traditional Unix systems are declining.
Q2: What is the Linux kernel?
Answer: The kernel is the core of the operating system that manages hardware resources. It handles process scheduling, memory management, device drivers, file systems, and networking. Linux uses a monolithic kernel design — all core services run in kernel space for performance, though loadable kernel modules allow extending functionality without rebooting. You can check your kernel version with uname -r.
Q3: Explain the Linux boot process.
Answer: The boot sequence follows these steps:
- BIOS/UEFI — hardware initialization, POST (Power-On Self-Test)
- Bootloader (GRUB2) — loads the kernel image into memory
- Kernel initialization — detects hardware, mounts root filesystem (initially as read-only)
- init/systemd (PID 1) — first userspace process, starts system services
- Runlevel/target reached — system ready for user login
# Check current systemd target (equivalent of runlevel)
systemctl get-default
# View boot messages
dmesg | head -50
journalctl -bQ4: What are inodes?
Answer: An inode is a data structure that stores metadata about a file — permissions, owner, size, timestamps, and pointers to data blocks on disk. Every file and directory has a unique inode number within its filesystem. The filename is NOT stored in the inode — it is stored in the directory entry that maps names to inode numbers. This is why hard links work: multiple directory entries can point to the same inode.
# View inode number
ls -i filename.txt
# Check inode usage
df -iIntermediate Questions
Q5: Explain file permissions in Linux.
Answer: Every file has three permission sets: owner (u), group (g), and others (o). Each set has three permissions: read (r=4), write (w=2), execute (x=1). Permissions are displayed as a 10-character string like -rwxr-xr--, where the first character indicates file type (- for regular, d for directory, l for symlink).
# Change permissions (numeric)
chmod 755 script.sh # rwxr-xr-x
# Change permissions (symbolic)
chmod u+x,g-w file.txt
# Change ownership
chown user:group file.txtFor directories, read means listing contents, write means creating/deleting files inside, and execute means accessing (cd into) the directory.
Q6: What is the difference between hard links and soft links?
Answer: A hard link is an additional directory entry pointing to the same inode. Both names are equal — deleting one does not affect the other. Hard links cannot cross filesystem boundaries and cannot link to directories. A soft (symbolic) link is a separate file that contains the path to the target. If the target is deleted, the symlink becomes a dangling reference.
# Create hard link
ln original.txt hardlink.txt
# Create soft link
ln -s /path/to/original.txt symlink.txt
# Verify — same inode for hard links
ls -li original.txt hardlink.txtQ7: How do you find and kill a process?
Answer:
# Find process by name
ps aux | grep nginx
pgrep -a nginx
# Kill gracefully (SIGTERM)
kill PID
kill -15 PID
# Force kill (SIGKILL — cannot be caught)
kill -9 PID
# Kill by name
pkill nginx
killall nginx
# Find which process uses a port
lsof -i :8080
ss -tlnp | grep 8080SIGTERM (15) allows the process to clean up. SIGKILL (9) immediately terminates it — use only when SIGTERM fails.
Q8: Explain the /proc filesystem.
Answer: /proc is a virtual filesystem that provides a window into the kernel's view of the system. It does not exist on disk — files are generated dynamically when read. Key entries:
/proc/cpuinfo— CPU details/proc/meminfo— memory usage/proc/[PID]/— information about a specific process/proc/[PID]/status— process state, memory usage/proc/[PID]/fd/— open file descriptors
# Check total memory
cat /proc/meminfo | grep MemTotal
# See process command line
cat /proc/1234/cmdline
# Count open files for a process
ls /proc/1234/fd | wc -lAdvanced Questions
Q9: What happens when you type a command and press Enter?
Answer: The shell performs these steps:
- Tokenization — splits input into command and arguments
- Expansion — expands variables ($HOME), globs (*.txt), command substitution ($(cmd))
- Command lookup — checks aliases, then functions, then builtins, then searches $PATH directories
- fork() — creates a child process (copy of shell)
- exec() — replaces child process image with the command's binary
- wait() — parent shell waits for child to complete (unless backgrounded with &)
- Exit status — shell stores the return code in $?
Q10: How do you troubleshoot a slow Linux system?
Answer: Systematic diagnosis:
# 1. Check load average
uptime
# Load > number of CPUs = overloaded
# 2. Identify CPU-heavy processes
top -o %CPU
# or
htop
# 3. Check memory pressure
free -h
# Look at available (not just free)
# 4. Check disk I/O
iostat -x 1 5
iotop
# 5. Check disk space
df -h
# Full disk causes many failures
# 6. Check network
ss -s
netstat -an | grep ESTABLISHED | wc -l
# 7. Check logs
tail -100 /var/log/syslog
journalctl -p err --since "1 hour ago"Q11: Explain the difference between processes and threads in Linux.
Answer: In Linux, both processes and threads are created with clone() system call — the difference is what they share. A process has its own memory space, file descriptor table, and PID. Threads within the same process share memory space and file descriptors but have separate stacks and thread IDs. Linux implements threads as "lightweight processes" — the kernel schedules them identically, but threads sharing memory have lower context-switch overhead since TLB flush is not needed.
Q12: What is a zombie process and how do you handle it?
Answer: A zombie is a process that has finished execution but whose parent has not yet called wait() to read its exit status. It occupies a slot in the process table but consumes no other resources. You cannot kill a zombie (it is already dead) — you must either fix the parent to call wait(), or kill the parent process so init/systemd adopts and reaps the zombie.
# Find zombies
ps aux | awk '$8=="Z"'
# Find zombie's parent
ps -o ppid= -p ZOMBIE_PIDShell Scripting Questions
Q13: Write a script to find files larger than 100MB modified in the last 7 days.
#!/bin/bash
find / -type f -size +100M -mtime -7 -exec ls -lh {} \; 2>/dev/nullQ14: What is the difference between $@ and $* in shell scripts?
Answer: Both represent all positional parameters, but they differ when quoted. "$@" expands each argument as a separate quoted string (preserving spaces within arguments). "$*" expands all arguments as a single string joined by IFS. Always use "$@" when passing arguments to another command to preserve argument boundaries.
Key Points for Interview Success
- Always explain the "why" — not just the command but when and why you would use it
- Mention edge cases and failure scenarios
- Demonstrate troubleshooting methodology (systematic, not random guessing)
- Know the difference between "I read about it" and "I have used it in production"
- Be honest about what you do not know — then explain how you would find the answer
Exam Focus
Revise definitions, diagrams, examples, and short-answer points for Linux Interview Questions.
Interview Use
Prepare one clear explanation, one practical example, and one common mistake for this Operating Systems topic.
Search Terms
operating-systems, operating systems, operating, systems, interview, preparation, linux, questions
Related Operating Systems Topics