Top 50 Linux Interview Questions
For Embedded Linux, Automotive Linux, BSP, Device Driver, Middleware, and Senior Embedded Software Engineer (5–15 years) interviews, Linux and OS questions typically focus on processes, memory, scheduling, synchronization, file systems, IPC, networking, and kernel internals.
Below is a comprehensive interview question bank.
1. Operating System Basics
Q1. What is an Operating System?
Answer:
An Operating System (OS) is software that manages computer hardware and provides services to applications.
Responsibilities:
- Process management
- Memory management
- File system
- Device management
- Networking
- Security
Q2. What are the major components of an OS?
- Kernel
- Process Manager
- Memory Manager
- File System
- Device Drivers
- Scheduler
- IPC
- System Call Interface
Q3. What is Kernel?
The kernel is the core part of the operating system that runs in privileged mode and directly manages hardware resources.
Q4. User Space vs Kernel Space
| User Space | Kernel Space |
|---|---|
| Applications | OS Kernel |
| Limited privileges | Full hardware access |
| Cannot access hardware directly | Can access hardware directly |
| Uses system calls | Executes kernel code |
Q5. What is a System Call?
A system call is the interface through which a user-space application requests services from the kernel.
Examples:
-
open() -
read() -
write() -
fork() -
exec() -
mmap()
2. Process Management
Q6. What is a Process?
A process is a program in execution with its own address space and resources.
Q7. Process vs Thread
| Process | Thread |
|---|---|
| Separate memory | Shared memory |
| Heavyweight | Lightweight |
| IPC required | Easy communication |
| Separate PCB | Shares process resources |
Q8. Process States
- New
- Ready
- Running
- Waiting (Blocked)
- Terminated
Q9. Process Control Block (PCB)
Contains:
- PID
- Registers
- Program Counter
- Stack Pointer
- Scheduling information
- Memory information
- Open files
Q10. What is Context Switching?
Saving the state of one process/thread and restoring another.
Saved information:
- CPU registers
- Program Counter
- Stack Pointer
- Processor Status
Q11. What causes Context Switch?
- Interrupt
- Higher priority task
- Blocking system call
- Time slice expiration
- Scheduler decision
Q12. fork() vs exec()
| fork() | exec() |
|---|---|
| Creates new process | Replaces current process image |
| Child gets copy | Same PID after replacement |
| Returns twice | Does not return on success |
Q13. Zombie Process
A process that has terminated but whose exit status has not yet been collected by its parent.
Q14. Orphan Process
A process whose parent exits before it does. It is adopted by the init/systemd process.
3. Threads
Q15. What is a Thread?
A thread is the smallest unit of CPU execution within a process.
Q16. Advantages of Multithreading
- Better CPU utilization
- Faster execution
- Shared memory
- Lower context-switch cost
- Improved responsiveness
Q17. Thread Synchronization
- Mutex
- Semaphore
- Condition Variable
- Read-Write Lock
- Spinlock
4. Scheduling
Q18. CPU Scheduling Algorithms
- FCFS
- SJF
- Round Robin
- Priority Scheduling
- Multilevel Queue
- Multilevel Feedback Queue
- EDF (Real-Time)
Q19. Linux Scheduler
Modern Linux uses the Completely Fair Scheduler (CFS) for normal tasks. Real-time tasks use fixed-priority scheduling classes such as SCHED_FIFO and SCHED_RR.
Q20. What is Time Slice?
The amount of CPU time allocated to a process before the scheduler may switch to another runnable process.
Q21. What is Starvation?
A process waits indefinitely because other processes continually receive CPU time or resources first.
Q22. What is Aging?
Gradually increasing the priority of waiting processes to prevent starvation.
5. Memory Management
Q23. Virtual Memory
Allows processes to use virtual addresses mapped to physical memory by the MMU.
Q24. Paging
Memory is divided into fixed-size pages and mapped to physical frames.
Q25. Segmentation
Memory is divided into logical segments (code, data, stack). Many modern systems primarily rely on paging.
Q26. Page Fault
Occurs when a referenced page is not currently in physical memory and must be loaded.
Q27. Demand Paging
Pages are loaded only when first accessed.
Q28. Thrashing
The system spends most of its time swapping pages instead of executing useful work.
Q29. Stack vs Heap
| Stack | Heap |
|---|---|
| Automatic allocation | Dynamic allocation |
| Faster | Slower |
| LIFO | Arbitrary allocation |
| Limited size | Larger but can fragment |
Q30. Memory Leak
Memory is allocated but never freed, making it unavailable until the process exits.
Q31. Fragmentation
- Internal Fragmentation
- External Fragmentation
Q32. mmap()
Maps files or anonymous memory into a process's address space.
6. Synchronization
Q33. Mutex vs Semaphore
| Mutex | Semaphore |
|---|---|
| Ownership | No ownership |
| Mutual exclusion | Signaling/resource counting |
| Binary | Binary or Counting |
Q34. Binary Semaphore vs Counting Semaphore
Binary:
- 0 or 1
Counting:
- Counts multiple available resources
Q35. Spinlock vs Mutex
| Spinlock | Mutex |
|---|---|
| Busy wait | Sleeps while waiting |
| Short critical sections | Longer waits |
| Common in kernel | Common in user space and kernel |
Q36. Critical Section
A code section accessing shared resources that must not be executed concurrently.
7. Deadlock
Q37. What is Deadlock?
Two or more processes wait forever for resources held by each other.
Q38. Necessary Conditions
- Mutual Exclusion
- Hold and Wait
- No Preemption
- Circular Wait
Q39. Deadlock Prevention
- Resource ordering
- Timeouts
- Avoid nested locks
- Lock hierarchy
8. IPC (Inter-Process Communication)
Q40. IPC Mechanisms
- Pipe
- Named Pipe (FIFO)
- Message Queue
- Shared Memory
- Semaphore
- Socket
- Signals
Q41. Shared Memory
Fastest IPC because processes communicate through a common memory region.
Q42. Pipe vs FIFO
Pipe:
- Related processes
- Anonymous
FIFO:
- Unrelated processes
- Named
Q43. Socket vs Pipe
Sockets support communication across machines, while pipes are generally local.
9. Linux File System
Q44. Inode
Stores metadata such as permissions, ownership, timestamps, and pointers to file data (not the filename itself).
Q45. Hard Link vs Soft Link
| Hard Link | Soft Link |
|---|---|
| Same inode | Different inode |
| Survives original filename deletion | Breaks if target removed |
| Same filesystem | Can span filesystems |
Q46. File Permissions
rwxr-xr--
- Read
- Write
- Execute
Q47. chmod
Changes file permissions.
Q48. chown
Changes file owner and/or group.
10. Linux Boot Process
Q49. Boot Sequence
- BIOS/UEFI
- Bootloader (e.g., GRUB/U-Boot)
- Kernel
- init/systemd
- User applications
Q50. What is init/systemd?
The first user-space process (PID 1) responsible for starting services and managing the system.
11. Linux Commands
Common interview commands:
-
ps -
top/htop -
kill -
grep -
find -
ls -
chmod -
df -
du -
free -
vmstat -
netstat/ss -
dmesg -
journalctl
12. Networking
Q51. TCP vs UDP
| TCP | UDP |
|---|---|
| Reliable | Unreliable |
| Connection-oriented | Connectionless |
| Ordered delivery | No ordering guarantee |
| Higher overhead | Lower overhead |
Q52. Socket Programming Steps
Server:
-
socket() -
bind() -
listen() -
accept() -
read()/write()
Client:
-
socket() -
connect() -
read()/write()
13. Device Drivers
Q53. What is a Device Driver?
Software that enables the kernel to communicate with hardware.
Q54. Character vs Block Driver
| Character | Block |
|---|---|
| Stream of bytes | Fixed-size blocks |
| UART, keyboard | Disk, SSD |
Q55. User Space vs Kernel Driver
Kernel drivers run with full privileges and interact directly with hardware. User-space drivers are easier to develop and debug but have limitations.
14. Embedded Linux
Q56. What is Device Tree?
A hardware description used by the Linux kernel to discover devices without hardcoding platform details.
Q57. What is U-Boot?
A widely used bootloader in embedded Linux systems.
Q58. What is BusyBox?
A compact collection of Unix utilities designed for embedded systems.
Q59. Cross Compilation
Building software on one architecture (e.g., x86) to run on another (e.g., ARM).
Q60. Yocto vs Buildroot
| Yocto | Buildroot |
|---|---|
| Highly customizable distribution builder | Simpler embedded build system |
| Suitable for complex products | Faster for smaller projects |
Scenario-Based Questions
- Why is your Linux application consuming 100% CPU?
- How would you debug a memory leak?
- A process is stuck in the D (uninterruptible sleep) state. What could cause it?
-
Why is a process not responding to
kill -9? - How do you debug a segmentation fault?
-
Explain what happens when you call
fork()followed byexec(). - How would you synchronize multiple threads accessing a CAN or UART driver?
- How do you investigate a system that is running out of memory?
-
What is the difference between
select(),poll(), andepoll()? - How would you reduce boot time in an embedded Linux system?
Frequently Asked Linux APIs
-
Process:
fork(),exec(),wait(),waitpid(),exit() -
Threads:
pthread_create(),pthread_join(),pthread_mutex_lock() -
Files:
open(),read(),write(),close(),lseek() -
Memory:
malloc(),free(),mmap(),munmap() -
IPC:
pipe(),shmget(),msgsnd(),sem_wait(),socket() -
Signals:
signal(),sigaction(),kill()
These questions cover the concepts most commonly asked in Embedded Linux, BSP, Device Driver, Automotive Linux, and Middleware interviews. If you're preparing for companies such as Bosch, Continental, Aptiv, Harman, Qualcomm, NVIDIA, Intel, Mercedes-Benz, or Volvo, mastering these topics along with RTOS, AUTOSAR, networking, and C programming will give you a strong technical foundation.
Post a Comment