Header Ads

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 SpaceKernel Space
ApplicationsOS Kernel
Limited privilegesFull hardware access
Cannot access hardware directlyCan access hardware directly
Uses system callsExecutes 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

ProcessThread
Separate memoryShared memory
HeavyweightLightweight
IPC requiredEasy communication
Separate PCBShares 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 processReplaces current process image
Child gets copySame PID after replacement
Returns twiceDoes 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

StackHeap
Automatic allocationDynamic allocation
FasterSlower
LIFOArbitrary allocation
Limited sizeLarger 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

MutexSemaphore
OwnershipNo ownership
Mutual exclusionSignaling/resource counting
BinaryBinary or Counting

Q34. Binary Semaphore vs Counting Semaphore

Binary:

  • 0 or 1

Counting:

  • Counts multiple available resources

Q35. Spinlock vs Mutex

SpinlockMutex
Busy waitSleeps while waiting
Short critical sectionsLonger waits
Common in kernelCommon 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 LinkSoft Link
Same inodeDifferent inode
Survives original filename deletionBreaks if target removed
Same filesystemCan 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

  1. BIOS/UEFI
  2. Bootloader (e.g., GRUB/U-Boot)
  3. Kernel
  4. init/systemd
  5. 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

TCPUDP
ReliableUnreliable
Connection-orientedConnectionless
Ordered deliveryNo ordering guarantee
Higher overheadLower 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

CharacterBlock
Stream of bytesFixed-size blocks
UART, keyboardDisk, 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

YoctoBuildroot
Highly customizable distribution builderSimpler embedded build system
Suitable for complex productsFaster for smaller projects

Scenario-Based Questions

  1. Why is your Linux application consuming 100% CPU?
  2. How would you debug a memory leak?
  3. A process is stuck in the D (uninterruptible sleep) state. What could cause it?
  4. Why is a process not responding to kill -9?
  5. How do you debug a segmentation fault?
  6. Explain what happens when you call fork() followed by exec().
  7. How would you synchronize multiple threads accessing a CAN or UART driver?
  8. How do you investigate a system that is running out of memory?
  9. What is the difference between select(), poll(), and epoll()?
  10. 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.