Linux System Programming – Complete Interview Question Bank

1. Linux System Programming Fundamentals

Basic Concepts

  1. What is Linux System Programming?
  2. What is the difference between System Programming and Application Programming?
  3. What is a Linux system call?
  4. Why do we need system calls?
  5. What happens internally when a system call is called?
  6. What is the difference between user space and kernel space?
  7. What is a context switch?
  8. What causes a context switch?
  9. What is process context?
  10. What is interrupt context?
  11. What is kernel mode?
  12. What is user mode?
  13. How does a program transition from user mode to kernel mode?
  14. What is the system call interface?
  15. What is libc?
  16. Difference between glibc, libc and system calls.
  17. What is POSIX?
  18. Linux vs POSIX?
  19. What is a POSIX API?
  20. What is an API vs ABI?
  21. What is errno?
  22. How is errno implemented?
  23. Why should you not directly check errno after every function?
  24. What does perror() do?
  25. Difference between perror() and strerror().

2. Processes

This is one of the most important interview areas.

Process Basics

  1. What is a process?
  2. Process vs program?
  3. Process vs thread?
  4. What are the different process states?
  5. What is PID?
  6. What is PPID?
  7. What is process ID 1?
  8. What is a parent process?
  9. What is a child process?
  10. What is an orphan process?
  11. What is a zombie process?
  12. How does a process become zombie?
  13. How does the parent remove a zombie?
  14. What happens if the parent terminates before the child?
  15. Who adopts an orphan process?
  16. What is process hierarchy?
  17. How can you see process hierarchy in Linux?
  18. What is ps?
  19. What is /proc/<pid>?

3. fork()

  1. What is fork()?
  2. What does fork() return?
  3. What happens internally during fork()?
  4. Does fork() copy the entire process memory?
  5. What is Copy-on-Write (COW)?
  6. Why is Copy-on-Write used?
  7. What happens to global variables after fork()?
  8. What happens to stack after fork()?
  9. What happens to heap after fork()?
  10. What happens to file descriptors after fork()?
  11. Does child inherit environment variables?
  12. Does child inherit signal handlers?
  13. Does child inherit pending signals?
  14. Does child inherit mutexes?
  15. What happens to threads after fork() in a multithreaded process?
  16. What is fork() + exec()?
  17. Why is fork() commonly followed by exec()?

Coding Questions

pid_t pid = fork();

if (pid == 0)
    printf("Child\n");
else if (pid > 0)
    printf("Parent\n");
else
    perror("fork");

Interviewers may ask:

How many times will this code execute?

4. exec()

Know all of these:

  • execl()
  • execlp()
  • execle()
  • execv()
  • execvp()
  • execve()

Questions:

  1. What does exec() do?
  2. Does exec() create a new process?
  3. Difference between fork() and exec().
  4. Why is exec() usually used with fork()?
  5. Difference between execv() and execvp().
  6. What happens to PID after exec()?
  7. What happens to open file descriptors after exec()?
  8. What is FD_CLOEXEC?
  9. What happens to memory after exec()?
  10. What happens to signal dispositions after exec()?
  11. Why can exec() fail?
  12. Explain fork() → exec() → wait().

5. Process Termination

  1. exit()
  2. _exit()
  3. _Exit()
  4. Difference between exit() and _exit().
  5. What happens when exit() is called?
  6. What are atexit() handlers?
  7. What happens to stdio buffers?
  8. Why is _exit() preferred in a child after fork() in certain cases?
  9. What is exit status?
  10. How does parent obtain child exit status?

6. wait() / waitpid()

  1. What is wait()?
  2. What is waitpid()?
  3. Difference between wait() and waitpid().
  4. What is WIFEXITED()?
  5. What is WEXITSTATUS()?
  6. What is WIFSIGNALED()?
  7. What is WTERMSIG()?
  8. What is WIFSTOPPED()?
  9. What is WSTOPSIG()?
  10. What is WIFCONTINUED()?
  11. What is blocking wait()?
  12. How do you perform non-blocking wait?
  13. How do you prevent zombie processes?

7. File Descriptors

This is extremely important for Linux interviews.

  1. What is a file descriptor?
  2. Why does Linux use file descriptors?
  3. What are standard file descriptors?
  4. stdin = 0
  5. stdout = 1
  6. stderr = 2
  7. What is a file descriptor table?
  8. What is an open file description?
  9. What is an inode?
  10. Explain relationship:
Process
   ↓
File Descriptor
   ↓
Open File Description
   ↓
Inode
   ↓
File
  1. What does open() return?
  2. What happens internally when open() is called?
  3. What happens when close() is called?
  4. What happens if you don’t close a file descriptor?
  5. What is FD leak?
  6. How do you detect FD leaks?
  7. What is the maximum number of FDs?
  8. What is ulimit -n?
  9. Difference between file descriptor and FILE pointer.
  10. Difference between fd and FILE *.

8. File Operations

Know:

open()
close()
read()
write()
pread()
pwrite()
lseek()
fcntl()
ioctl()
dup()
dup2()
dup3()

Questions:

  1. Explain open().
  2. Explain read().
  3. Explain write().
  4. Explain close().
  5. What does lseek() do?
  6. What is SEEK_SET?
  7. What is SEEK_CUR?
  8. What is SEEK_END?
  9. Can lseek() be used on a pipe?
  10. What happens if read() returns 0?
  11. What does partial read() mean?
  12. What does partial write() mean?
  13. Why can write() write fewer bytes than requested?
  14. Difference between blocking and non-blocking I/O.
  15. What is O_RDONLY?
  16. O_WRONLY?
  17. O_RDWR?
  18. O_CREAT?
  19. O_APPEND?
  20. O_TRUNC?
  21. O_EXCL?
  22. O_NONBLOCK?
  23. O_SYNC?
  24. O_DSYNC?
  25. O_CLOEXEC?

9. dup(), dup2(), dup3()

  1. What is dup()?
  2. What is dup2()?
  3. What is dup3()?
  4. Difference between dup() and dup2().
  5. How does shell output redirection work?

Example:

./program > output.txt
  1. How can you implement:
command > file

using system calls?

Answer involves:

open()
dup2()
close()
exec()

10. File I/O vs Standard I/O

  1. read() vs fread()
  2. write() vs fwrite()
  3. open() vs fopen()
  4. close() vs fclose()
  5. What is stdio buffering?
  6. Full buffering?
  7. Line buffering?
  8. Unbuffered I/O?
  9. Why does printf() not immediately write to terminal/file?
  10. What does fflush() do?
  11. Why can output be duplicated after fork()?

11. Pipes

  1. What is a pipe?
  2. How does pipe work?
  3. Is pipe unidirectional?
  4. What are anonymous pipes?
  5. What are named pipes?
  6. What is FIFO?
  7. Difference between pipe and FIFO.
  8. How is a pipe created?
  9. What does pipe() return?
  10. What happens when pipe buffer becomes full?
  11. What happens when no reader exists?
  12. What happens when no writer exists?
  13. What happens when all writers close the pipe?
  14. What does read() return on EOF?
  15. What happens when writing to a pipe with no reader?
  16. What is SIGPIPE?
  17. What is PIPE_BUF?
  18. Is pipe communication bidirectional?
  19. How can two processes communicate bidirectionally?

12. FIFO

  1. What is FIFO?
  2. Why is FIFO called named pipe?
  3. How do you create FIFO?
  4. mkfifo()
  5. FIFO vs regular file.
  6. FIFO vs anonymous pipe.
  7. Blocking behavior of FIFO.
  8. What happens when FIFO has no reader?
  9. What happens when FIFO has no writer?

13. IPC – Inter Process Communication

You should know all major IPC mechanisms:

Pipe
FIFO
Message Queue
Shared Memory
Semaphore
Socket
Signal

Questions:

  1. What is IPC?
  2. Why do processes need IPC?
  3. List Linux IPC mechanisms.
  4. Which IPC is fastest?
  5. Which IPC allows direct shared memory?
  6. Which IPC provides message boundaries?
  7. Which IPC is suitable for large data?
  8. Shared memory vs pipe.
  9. Message queue vs pipe.
  10. Semaphore vs mutex.
  11. Socket vs pipe.

14. Shared Memory

  1. What is shared memory?
  2. Why is shared memory fast?
  3. How do two processes share memory?
  4. What is shmget()?
  5. shmat()?
  6. shmdt()?
  7. shmctl()?
  8. POSIX shared memory?
  9. shm_open()
  10. mmap()
  11. Shared memory synchronization?
  12. Why does shared memory need synchronization?
  13. Shared memory vs message queue.
  14. Shared memory vs pipe.
  15. How would you implement producer-consumer using shared memory?

15. Message Queues

System V

msgget()
msgsnd()
msgrcv()
msgctl()

POSIX

mq_open()
mq_send()
mq_receive()
mq_close()
mq_unlink()

Questions:

  1. What is message queue?
  2. Message queue vs pipe.
  3. Why use message queues?
  4. What is message priority?
  5. What happens when queue is full?
  6. Blocking vs non-blocking message queue.
  7. POSIX vs System V message queues.

16. Signals

Another must-know topic.

  1. What is a signal?
  2. Why are signals used?
  3. Synchronous vs asynchronous signals.
  4. SIGINT
  5. SIGTERM
  6. SIGKILL
  7. SIGSTOP
  8. SIGSEGV
  9. SIGBUS
  10. SIGPIPE
  11. SIGCHLD
  12. SIGALRM
  13. SIGUSR1
  14. SIGUSR2
  15. What is signal handler?
  16. signal() vs sigaction().
  17. Why prefer sigaction()?
  18. What is signal masking?
  19. What is sigprocmask()?
  20. What is sigpending()?
  21. What is sigsuspend()?
  22. What is kill()?
  23. Does kill() always terminate a process?
  24. What does raise() do?
  25. What is pause()?
  26. What is a blocked signal?
  27. What is a pending signal?
  28. Can SIGKILL be caught?
  29. Can SIGSTOP be caught?
  30. What happens when multiple signals arrive?
  31. What are real-time signals?
  32. Standard vs real-time signals.
  33. What is signal-safe function?
  34. What functions can safely be called from signal handlers?

17. Threads

  1. What is a thread?
  2. Process vs thread.
  3. Why use threads?
  4. User-level vs kernel-level threads.
  5. What is POSIX thread?
  6. pthread_create()
  7. pthread_join()
  8. pthread_exit()
  9. pthread_self()
  10. pthread_cancel()
  11. What happens if thread function returns?
  12. Joinable vs detached thread.
  13. What is a detached thread?
  14. What happens if main thread exits?
  15. Thread stack?
  16. Thread-local storage?
  17. What does each thread share?
  18. What does each thread have independently?

Very common question:

What is shared between threads?

Answer:

Code
Data
Heap
Global variables
Open file descriptors
Address space

Each thread has its own:

Stack
Registers
Program counter
Thread ID

18. Mutex

  1. What is mutex?
  2. Why do we need mutex?
  3. pthread_mutex_init()
  4. pthread_mutex_lock()
  5. pthread_mutex_unlock()
  6. pthread_mutex_destroy()
  7. What is recursive mutex?
  8. Normal mutex?
  9. Error-checking mutex?
  10. Mutex vs semaphore.
  11. Mutex vs spinlock.
  12. What is deadlock?
  13. How does deadlock happen?
  14. How can deadlock be prevented?
  15. What is lock ordering?

19. Condition Variables

  1. What is condition variable?
  2. Why use condition variable?
  3. pthread_cond_wait()
  4. pthread_cond_signal()
  5. pthread_cond_broadcast()
  6. Why does pthread_cond_wait() release mutex?
  7. Why should condition variable be used with mutex?
  8. Why should while generally be used instead of if around condition waits?
  9. What is spurious wakeup?
  10. Producer-consumer using condition variables.

20. Semaphores

  1. What is semaphore?
  2. Binary semaphore?
  3. Counting semaphore?
  4. sem_init()
  5. sem_wait()
  6. sem_post()
  7. sem_trywait()
  8. sem_destroy()
  9. Mutex vs semaphore.
  10. Binary semaphore vs mutex.
  11. Counting semaphore use cases.
  12. Can a different thread unlock a mutex?
  13. Can a different thread call sem_post()?

21. Deadlock

Know the four Coffman conditions:

  1. Mutual exclusion
  2. Hold and wait
  3. No preemption
  4. Circular wait

Interview questions:

  • What is deadlock?
  • Give a real example.
  • How do you detect deadlock?
  • How do you prevent deadlock?
  • How can lock ordering prevent deadlock?
  • Deadlock vs starvation.
  • Deadlock vs livelock.

22. Race Conditions

  1. What is race condition?
  2. Give an example.
  3. How do you reproduce race conditions?
  4. How do you prevent race conditions?
  5. Mutex solution.
  6. Atomic operation solution.
  7. Race condition vs data race.
  8. Why does volatile NOT solve race conditions?
  9. Atomic vs volatile.

23. Synchronization

Know:

Mutex
Semaphore
Condition Variable
Spinlock
Read/Write Lock
Atomic Operations
Memory Barriers
Futex

Questions:

  1. Mutex vs semaphore.
  2. Mutex vs spinlock.
  3. Spinlock vs rwlock.
  4. Atomic operation vs mutex.
  5. What is memory ordering?
  6. What is memory barrier?
  7. What is futex()?
  8. Why are futexes important in Linux?

24. Scheduling

  1. What is CPU scheduling?
  2. Preemptive scheduling?
  3. Cooperative scheduling?
  4. Process priority?
  5. Nice value?
  6. nice()
  7. setpriority()
  8. Real-time scheduling?
  9. SCHED_FIFO
  10. SCHED_RR
  11. SCHED_OTHER
  12. SCHED_DEADLINE
  13. What is priority inversion?
  14. Priority inheritance?
  15. Priority ceiling?

25. CPU Affinity

  1. What is CPU affinity?
  2. Why pin a thread/process to a CPU?
  3. sched_setaffinity()
  4. sched_getaffinity()
  5. Why is CPU affinity useful in real-time/embedded systems?

26. mmap()

Extremely important for Embedded Linux.

  1. What is mmap()?
  2. Why use mmap()?
  3. Memory mapping?
  4. File-backed mapping?
  5. Anonymous mapping?
  6. MAP_SHARED
  7. MAP_PRIVATE
  8. PROT_READ
  9. PROT_WRITE
  10. PROT_EXEC
  11. MAP_ANONYMOUS
  12. MAP_FIXED
  13. munmap()
  14. msync()
  15. mprotect()
  16. madvise()
  17. mmap vs read/write.
  18. How can processes communicate using mmap?
  19. How does mmap relate to device drivers?
  20. Why do drivers expose mmap()?

27. Virtual Memory

  1. What is virtual memory?
  2. Why does Linux use virtual memory?
  3. Virtual address vs physical address.
  4. Page?
  5. Page table?
  6. MMU?
  7. TLB?
  8. Page fault?
  9. Minor page fault?
  10. Major page fault?
  11. Demand paging?
  12. Copy-on-write?
  13. Anonymous memory?
  14. File-backed memory?
  15. Swap?
  16. What happens during page fault?
  17. What is memory fragmentation?
  18. Internal vs external fragmentation.

28. brk() and mmap() / Heap

  1. How does malloc() obtain memory?
  2. What is brk()?
  3. What is sbrk()?
  4. Does malloc always use brk()?
  5. When does malloc use mmap()?
  6. What happens when free() is called?
  7. What is heap fragmentation?
  8. What is memory leak?
  9. How can memory leaks be detected?

29. select()

  1. What is select()?
  2. Why use select()?
  3. What is I/O multiplexing?
  4. What is fd_set?
  5. FD_ZERO()
  6. FD_SET()
  7. FD_CLR()
  8. FD_ISSET()
  9. What is timeout?
  10. Limitations of select().
  11. Why does select() modify fd_set?
  12. What is FD_SETSIZE?

30. poll()

  1. What is poll()?
  2. pollfd structure.
  3. POLLIN
  4. POLLOUT
  5. POLLERR
  6. POLLHUP
  7. POLLNVAL
  8. select() vs poll().
  9. Advantages of poll.

31. epoll()

Very important for advanced Linux interviews.

  1. What is epoll?
  2. Why was epoll introduced?
  3. epoll_create1()
  4. epoll_ctl()
  5. epoll_wait()
  6. EPOLLIN
  7. EPOLLOUT
  8. EPOLLERR
  9. EPOLLHUP
  10. Level-triggered epoll.
  11. Edge-triggered epoll.
  12. LT vs ET.
  13. Why must you use non-blocking I/O with ET?
  14. EPOLLONESHOT
  15. EPOLLEXCLUSIVE
  16. epoll vs select.
  17. epoll vs poll.
  18. How does epoll scale with thousands of FDs?

32. Non-Blocking I/O

  1. What is blocking I/O?
  2. What is non-blocking I/O?
  3. O_NONBLOCK
  4. What does EAGAIN mean?
  5. What does EWOULDBLOCK mean?
  6. How do you implement non-blocking read?
  7. Non-blocking socket.
  8. Non-blocking pipe.
  9. Non-blocking device driver.

33. Sockets

This is a huge interview topic.

Basics

  1. What is socket?
  2. What is socket programming?
  3. TCP vs UDP.
  4. Client-server architecture.
  5. What is IP address?
  6. What is port?
  7. What is protocol?
  8. What is socket family?
  9. AF_INET
  10. AF_INET6
  11. AF_UNIX

TCP

Know:

socket()
bind()
listen()
accept()
connect()
send()
recv()
close()

Questions:

  1. Explain TCP server flow.
  2. Explain TCP client flow.
  3. Why is listen() required?
  4. What does accept() return?
  5. Does accept() create a new socket?
  6. Difference between listening socket and connected socket.
  7. What is backlog?
  8. What happens if accept() isn’t called?
  9. What does connect() do?
  10. What happens when client closes connection?
  11. What does recv() return 0 mean?
  12. What is SO_REUSEADDR?
  13. What is SO_REUSEPORT?

34. UDP

  1. TCP vs UDP.
  2. Is UDP connection-oriented?
  3. Does UDP guarantee delivery?
  4. Does UDP preserve message boundaries?
  5. sendto()
  6. recvfrom()
  7. sendmsg()
  8. recvmsg()
  9. UDP broadcast.
  10. UDP multicast.

35. Unix Domain Sockets

Especially useful in Embedded Linux / Android.

  1. What is Unix domain socket?
  2. Why use Unix sockets?
  3. Unix socket vs TCP socket.
  4. AF_UNIX
  5. Stream vs datagram Unix sockets.
  6. Abstract namespace sockets.
  7. How can processes communicate through Unix sockets?

36. Socket I/O Multiplexing

Questions:

  1. How can one server handle multiple clients?
  2. Threads vs select.
  3. Threads vs epoll.
  4. select + socket.
  5. poll + socket.
  6. epoll + socket.
  7. Non-blocking socket + epoll.
  8. Reactor pattern.

37. File System

  1. What is filesystem?
  2. What is inode?
  3. What is directory?
  4. What is hard link?
  5. What is symbolic link?
  6. Hard link vs soft link.
  7. What is mount?
  8. What is mount point?
  9. What is /proc?
  10. What is /sys?
  11. What is /dev?
  12. What is /tmp?
  13. What is /etc?
  14. What is /var?
  15. What is /home?
  16. What is /run?
  17. What is tmpfs?
  18. What is procfs?
  19. What is sysfs?
  20. What is devtmpfs?

38. Directory APIs

Know:

opendir()
readdir()
closedir()
rewinddir()
seekdir()
telldir()

Questions:

  1. How do you list directory contents from C?
  2. What does readdir() return?
  3. What is struct dirent?
  4. What is d_name?
  5. How do you recursively traverse a directory?

39. File Metadata

Know:

stat()
fstat()
lstat()

Questions:

  1. Difference between stat() and lstat().
  2. stat() vs fstat().
  3. What is struct stat?
  4. File size?
  5. File permissions?
  6. File type?
  7. Access time?
  8. Modification time?
  9. Change time?
  10. What is st_mode?
  11. What is S_ISREG()?
  12. S_ISDIR()?
  13. S_ISLNK()?

40. Permissions

  1. Linux file permissions.
  2. Owner/group/others.
  3. rwx.
  4. Numeric permissions.
  5. chmod().
  6. chown().
  7. fchmod().
  8. umask().
  9. What is umask?
  10. What happens when creating a file?
  11. SUID?
  12. SGID?
  13. Sticky bit?
  14. ACL?
  15. Capability?

41. Links

  1. Hard link?
  2. Soft link?
  3. link()
  4. unlink()
  5. symlink()
  6. readlink()
  7. Why can’t directories normally have hard links created by users?
  8. What happens when original file is deleted?

42. Daemons

  1. What is daemon?
  2. Foreground vs background process.
  3. How do you create daemon?
  4. What is daemonization?
  5. Why call fork()?
  6. Why call setsid()?
  7. Why change working directory?
  8. Why redirect stdin/stdout/stderr?
  9. Why close inherited FDs?
  10. What is a session?
  11. What is process group?
  12. What is controlling terminal?

43. Sessions & Process Groups

  1. What is process group?
  2. What is process group ID?
  3. What is session?
  4. What is session leader?
  5. What is controlling terminal?
  6. setsid()
  7. setpgid()
  8. getsid()
  9. getpgrp()
  10. Why are process groups needed for job control?

44. Terminal / TTY

  1. What is TTY?
  2. What is pseudo-terminal?
  3. PTY vs TTY.
  4. What is /dev/tty?
  5. /dev/pts?
  6. What is terminal driver?
  7. What is terminal line discipline?
  8. What is canonical mode?
  9. What is raw mode?
  10. termios.

45. Memory Management

  1. malloc()
  2. calloc()
  3. realloc()
  4. free()
  5. memset()
  6. memcpy()
  7. memmove()
  8. memcmp()
  9. Memory leak.
  10. Double free.
  11. Use-after-free.
  12. Buffer overflow.
  13. Dangling pointer.
  14. Heap corruption.
  15. Stack overflow.
  16. Memory alignment.
  17. Memory fragmentation.
  18. How do you debug memory corruption?

46. memcpy() vs memmove()

  1. Difference?
  2. What happens with overlapping memory?
  3. Why can memcpy() fail with overlapping regions?
  4. Implementation-level difference.

47. Memory Alignment

  1. What is alignment?
  2. Why is alignment important?
  3. Aligned vs unaligned access.
  4. ARM alignment behavior.
  5. Structure alignment.
  6. Padding.
  7. posix_memalign()
  8. aligned_alloc().

48. ioctl()

Especially important for device-driver interviews.

  1. What is ioctl?
  2. Why use ioctl?
  3. Why can’t normal read/write handle everything?
  4. How does ioctl work?
  5. What is ioctl command number?
  6. _IO()
  7. _IOR()
  8. _IOW()
  9. _IOWR()
  10. What is direction?
  11. What is command magic number?
  12. What is command number?
  13. How does userspace communicate with driver through ioctl?
  14. Why must kernel validate user pointers?
  15. copy_to_user()
  16. copy_from_user().

49. fcntl()

  1. What is fcntl()?
  2. File descriptor duplication.
  3. File descriptor flags.
  4. File status flags.
  5. F_GETFD
  6. F_SETFD
  7. F_GETFL
  8. F_SETFL
  9. FD_CLOEXEC
  10. File locking with fcntl().

50. File Locking

  1. What is file locking?
  2. Advisory locking?
  3. Mandatory locking?
  4. flock()
  5. fcntl() locking.
  6. Shared lock?
  7. Exclusive lock?
  8. Blocking vs non-blocking lock.

51. Timers

Know:

sleep()
usleep()
nanosleep()
alarm()
setitimer()
timer_create()
timer_settime()
timerfd_create()

Questions:

  1. sleep() vs nanosleep().
  2. Why is usleep() obsolete?
  3. What is POSIX timer?
  4. What is timerfd?
  5. Timer vs sleep.
  6. Periodic timer?
  7. Absolute vs relative timer.
  8. CLOCK_MONOTONIC vs CLOCK_REALTIME.

52. Time APIs

  1. time()
  2. gettimeofday()
  3. clock_gettime()
  4. clock_settime()
  5. CLOCK_REALTIME
  6. CLOCK_MONOTONIC
  7. CLOCK_MONOTONIC_RAW
  8. CLOCK_PROCESS_CPUTIME_ID
  9. CLOCK_THREAD_CPUTIME_ID

Very common:

Why should timeout logic generally use CLOCK_MONOTONIC instead of CLOCK_REALTIME?

53. /proc

Extremely important in Linux.

  1. What is proc filesystem?
  2. Why is /proc called virtual filesystem?
  3. /proc/cpuinfo
  4. /proc/meminfo
  5. /proc/interrupts
  6. /proc/ioports
  7. /proc/iomem
  8. /proc/mounts
  9. /proc/modules
  10. /proc/<pid>/status
  11. /proc/<pid>/maps
  12. /proc/<pid>/fd
  13. /proc/<pid>/cmdline
  14. /proc/<pid>/stat
  15. /proc/loadavg

54. /sys / sysfs

  1. What is sysfs?
  2. Difference between /proc and /sys.
  3. What is kobject?
  4. What is sysfs attribute?
  5. What is /sys/class?
  6. What is /sys/devices?
  7. What is /sys/bus?
  8. How do drivers expose information through sysfs?

55. Environment Variables

  1. What is environment variable?
  2. getenv()
  3. setenv()
  4. unsetenv()
  5. putenv()
  6. How does child inherit environment?
  7. How does execve() handle environment?

56. Dynamic Linking

  1. Static linking vs dynamic linking.
  2. What is shared library?
  3. .so file?
  4. .a file?
  5. What is ELF?
  6. What is dynamic linker?
  7. What is ld.so?
  8. What is LD_LIBRARY_PATH?
  9. What is RPATH?
  10. What is RUNPATH?
  11. What is symbol resolution?
  12. What is lazy binding?
  13. What is PLT?
  14. What is GOT?
  15. What is dlopen()?
  16. dlsym()
  17. dlclose()
  18. dlerror().

57. ELF

  1. What is ELF?
  2. ELF header?
  3. Program header?
  4. Section header?
  5. .text
  6. .data
  7. .bss
  8. .rodata
  9. Symbol table.
  10. Relocation.
  11. Static vs dynamic ELF.
  12. readelf.
  13. objdump.
  14. nm.
  15. ldd.

58. System Call Tracing

strace

Know:

strace ./program
strace -f ./program
strace -p PID
strace -e trace=file ./program
strace -e trace=network ./program

Questions:

  1. What is strace?
  2. How does strace work?
  3. How do you trace child processes?
  4. How do you trace file operations?
  5. How do you trace network calls?
  6. What is ptrace()?
  7. How does debugger use ptrace?

59. Debugging

GDB

Know:

break
run
continue
next
step
finish
print
display
watch
info registers
info threads
backtrace
thread

Questions:

  1. How do you debug segmentation fault?
  2. What is core dump?
  3. How do you enable core dump?
  4. What is ulimit -c?
  5. How do you analyze core dump?
  6. What is GDB?
  7. Attach GDB to running process?
  8. Debug multithreaded application?
  9. Debug deadlock?
  10. Debug memory corruption?

60. Core Dump

  1. What is core dump?
  2. Why is core dump generated?
  3. How to enable core dump?
  4. What is ulimit -c unlimited?
  5. How do you analyze core?
  6. What information does core contain?
  7. What is a segmentation fault?
  8. SIGSEGV vs SIGBUS.

61. Linux IPC – Advanced

Know:

eventfd
signalfd
timerfd
memfd
pidfd
futex

Questions:

  1. What is eventfd?
  2. Why use eventfd?
  3. eventfd vs pipe.
  4. What is signalfd?
  5. Why use signalfd?
  6. What is timerfd?
  7. Why combine timerfd with epoll?
  8. What is pidfd?
  9. Why is pidfd useful?
  10. What is futex?
  11. How does pthread mutex relate to futex?

62. Asynchronous I/O

  1. What is asynchronous I/O?
  2. Synchronous vs asynchronous I/O.
  3. POSIX AIO.
  4. aio_read()
  5. aio_write()
  6. io_uring.
  7. What is io_uring?
  8. Why was io_uring introduced?
  9. io_uring vs epoll.
  10. Blocking vs non-blocking vs asynchronous I/O.

63. io_uring

For modern Linux interviews:

  1. What is io_uring?
  2. Submission Queue?
  3. Completion Queue?
  4. SQE?
  5. CQE?
  6. Why can io_uring reduce syscall overhead?
  7. io_uring vs epoll.

64. Namespaces

Important for modern Linux.

  1. What is Linux namespace?
  2. Why are namespaces used?
  3. PID namespace.
  4. Mount namespace.
  5. Network namespace.
  6. IPC namespace.
  7. UTS namespace.
  8. User namespace.
  9. Cgroup namespace.
  10. Time namespace.

65. Cgroups

  1. What are cgroups?
  2. Why use cgroups?
  3. CPU limits.
  4. Memory limits.
  5. I/O limits.
  6. Process accounting.
  7. cgroups vs namespaces.
  8. How containers use cgroups.

66. Containers

  1. What is Linux container?
  2. Container vs VM.
  3. How do namespaces provide isolation?
  4. How do cgroups provide resource control?
  5. What is Docker fundamentally using from Linux?

67. Capabilities

  1. What are Linux capabilities?
  2. Why capabilities?
  3. Root vs capabilities.
  4. CAP_NET_ADMIN
  5. CAP_SYS_ADMIN
  6. CAP_SYS_PTRACE
  7. Effective capabilities.
  8. Permitted capabilities.
  9. Inheritable capabilities.

68. Security

  1. File permissions.
  2. ACL.
  3. Capabilities.
  4. SELinux.
  5. AppArmor.
  6. ASLR.
  7. NX bit.
  8. Stack canary.
  9. PIE.
  10. RELRO.

69. Boot & Process Startup

For Embedded Linux, know:

Boot ROM
 ↓
Bootloader
 ↓
Linux Kernel
 ↓
init
 ↓
systemd / init system
 ↓
Services
 ↓
Application

Questions:

  1. What happens after kernel boot?
  2. What is init?
  3. Why is PID 1 special?
  4. What is systemd?
  5. What is service?
  6. What is daemon?
  7. How does systemd start services?
  8. What is target?
  9. What is unit?
  10. What is journal?

70. Linux Logging

  1. syslog()
  2. openlog()
  3. closelog()
  4. logger
  5. journald.
  6. journalctl.
  7. Kernel logs vs application logs.
  8. dmesg.
  9. Log levels.

71. Kernel ↔ User Space Communication

Very important for your Embedded Linux/device-driver interviews.

Know:

System Calls
ioctl
sysfs
procfs
debugfs
netlink
mmap
signals
device files

Questions:

  1. How does userspace communicate with kernel?
  2. ioctl vs sysfs.
  3. sysfs vs procfs.
  4. debugfs?
  5. What is netlink?
  6. Why use mmap in drivers?
  7. How does /dev communicate with drivers?
  8. What happens when userspace opens /dev/mydevice?

72. Device Files

  1. What is /dev?
  2. Character device vs block device.
  3. What is major number?
  4. What is minor number?
  5. What is mknod()?
  6. What is udev?
  7. How are device nodes created?
  8. What happens during:
open("/dev/mydevice", ...);
  1. How does VFS reach driver?
  2. What is file_operations?

73. VFS

  1. What is VFS?
  2. Why does Linux need VFS?
  3. What is inode?
  4. What is dentry?
  5. What is struct file?
  6. What is superblock?
  7. What is filesystem object?
  8. Explain:
Application
 ↓
System Call
 ↓
VFS
 ↓
Filesystem
 ↓
Block Layer
 ↓
Device Driver
 ↓
Hardware
  1. Difference between inode and struct file.
  2. What is dentry cache?

74. Linux Performance

Know these tools:

top
htop
ps
vmstat
iostat
sar
free
uptime
time
perf
strace
ltrace
pidstat
mpstat
iotop
ftrace

Questions:

  1. How do you find CPU bottleneck?
  2. How do you find memory bottleneck?
  3. How do you find I/O bottleneck?
  4. How do you identify high CPU process?
  5. How do you identify memory leak?
  6. How do you identify FD leak?
  7. How do you identify thread problems?
  8. How do you profile an application?

75. perf

  1. What is perf?
  2. CPU profiling.
  3. perf stat
  4. perf record
  5. perf report
  6. CPU cycles.
  7. Instructions.
  8. Cache misses.
  9. Context switches.
  10. Page faults.

76. ftrace

  1. What is ftrace?
  2. Function tracer.
  3. Function graph tracer.
  4. Tracepoints.
  5. kprobes.
  6. uprobes.
  7. How is ftrace different from strace?
  8. How do you investigate kernel latency?

77. Linux I/O Architecture

Understand:

Application
    ↓
read/write
    ↓
VFS
    ↓
Page Cache
    ↓
Filesystem
    ↓
Block Layer
    ↓
I/O Scheduler
    ↓
Device Driver
    ↓
Hardware

Questions:

  1. What is page cache?
  2. Buffered I/O?
  3. Direct I/O?
  4. O_DIRECT?
  5. O_SYNC?
  6. fsync()?
  7. fdatasync()?
  8. sync()?
  9. Why is write() not necessarily writing directly to disk?
  10. What happens when fsync() is called?

78. System Call Internals

For senior interviews:

  1. How does a system call work internally?
  2. What is syscall number?
  3. What happens during syscall entry?
  4. What happens during syscall return?
  5. What is syscall instruction?
  6. What is sysenter?
  7. ARM SVC instruction?
  8. x86 syscall mechanism?
  9. How are syscall arguments passed?
  10. What is syscall table?
  11. How does kernel return errno?

79. Error Handling

Know common errors:

EINTR
EAGAIN
EWOULDBLOCK
EINVAL
EBADF
ENOMEM
EACCES
EPERM
ENOENT
EEXIST
EPIPE
ECONNRESET
ETIMEDOUT
ENOSPC
EMFILE
ENFILE

Questions:

  1. Difference between EINTR and EAGAIN.
  2. What should you do if read() returns EINTR?
  3. What is EMFILE?
  4. EMFILE vs ENFILE.
  5. What is EPIPE?
  6. Why can write() return EPIPE?
  7. What is ECONNRESET?
  8. What is EINVAL?

80. Advanced Interview Scenarios

These are where experienced interviewers differentiate candidates.

Scenario 1

Parent creates child, child exits, but process remains in ps. Why?

→ Zombie.

Scenario 2

Two threads increment a global counter but final value is incorrect. Why?

→ Race condition.

Scenario 3

Application CPU usage suddenly becomes 100%. How do you debug?

top → identify PID → top -H / ps -Lperf → GDB.

Scenario 4

Application crashes randomly with SIGSEGV.

Discuss:

core dump
gdb
backtrace
ASAN
valgrind
memory corruption
race condition
use-after-free
stack corruption

Scenario 5

Server needs to handle 10,000 connections.

Discuss:

non-blocking sockets
epoll
event-driven architecture

Scenario 6

Two processes need to exchange a 10 MB buffer continuously.

Discuss:

Shared Memory
+
Synchronization

Scenario 7

You need to notify a process that data is ready.

Possible:

pipe
eventfd
signal
socket
shared memory + semaphore

Scenario 8

Application leaks file descriptors. How do you find it?

ls /proc/<pid>/fd

and:

lsof -p <pid>

Scenario 9

Application has memory leak.

Discuss:

Valgrind
ASan
heap profiling
/proc/<pid>/status

Scenario 10

Thread A waits for Thread B, while B waits for A.

→ Deadlock.

81. Must-Know Linux Commands for Interviews

You should be comfortable with:

ps
top
htop
pstree
pgrep
pkill
kill
killall
nice
renice
taskset
lsof
strace
ltrace
gdb
readelf
objdump
nm
ldd
file
size
strings
dmesg
journalctl
free
vmstat
iostat
sar
mpstat
pidstat
perf
ftrace
ip
ss
netstat
mount
umount
df
du
ls
find
stat
chmod
chown
ln

82. Top 50 Questions You Absolutely Must Master

If your interview is soon, prioritize these:

  1. What is a system call?
  2. User space vs kernel space?
  3. Process vs thread?
  4. fork()?
  5. Copy-on-write?
  6. exec()?
  7. fork() vs exec()?
  8. wait() vs waitpid()?
  9. Zombie vs orphan?
  10. File descriptor?
  11. File descriptor table?
  12. inode vs file descriptor?
  13. open/read/write/close?
  14. dup2()?
  15. fcntl()?
  16. Pipe?
  17. FIFO?
  18. Shared memory?
  19. Message queue?
  20. Semaphore?
  21. Signal?
  22. sigaction()?
  23. Signal masking?
  24. Mutex?
  25. Condition variable?
  26. Mutex vs semaphore?
  27. Race condition?
  28. Deadlock?
  29. Priority inversion?
  30. mmap()?
  31. Virtual memory?
  32. Page fault?
  33. select()?
  34. poll()?
  35. epoll()?
  36. LT vs ET?
  37. Blocking vs non-blocking I/O?
  38. TCP socket programming?
  39. TCP vs UDP?
  40. Unix domain socket?
  41. /proc?
  42. /sys?
  43. ioctl()?
  44. VFS?
  45. Device file?
  46. strace?
  47. GDB/core dump?
  48. perf?
  49. Dynamic linking/ELF?
  50. Kernel ↔ userspace communication?

83. Embedded Linux Interview Priority

Since you’re targeting Embedded Linux, don’t study every topic with equal depth.

🔴 Tier 1 – Must Master

Process
fork
exec
wait
File Descriptor
File I/O
Pipe
Signal
Thread
Mutex
Semaphore
Condition Variable
Race Condition
Deadlock
IPC
mmap
Virtual Memory
select
poll
epoll
Socket
ioctl
/proc
/sys
VFS
Device Files
System Calls

🟠 Tier 2 – Strongly Recommended

Shared Memory
Message Queue
FIFO
fcntl
File Locking
Timers
Scheduling
CPU Affinity
ELF
Dynamic Linking
Core Dump
GDB
strace
perf
ftrace
Daemon
TTY
Unix Domain Socket
Netlink
eventfd
timerfd
signalfd

🟡 Tier 3 – Advanced/Senior

io_uring
futex
Namespaces
Cgroups
Capabilities
SELinux
ASLR
PIE
RELRO
AIO
Memory Ordering
Advanced VFS
Syscall Internals
Kernel/User ABI

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *