1. Linux System Programming Fundamentals
Basic Concepts
- What is Linux System Programming?
- What is the difference between System Programming and Application Programming?
- What is a Linux system call?
- Why do we need system calls?
- What happens internally when a system call is called?
- What is the difference between user space and kernel space?
- What is a context switch?
- What causes a context switch?
- What is process context?
- What is interrupt context?
- What is kernel mode?
- What is user mode?
- How does a program transition from user mode to kernel mode?
- What is the system call interface?
- What is libc?
- Difference between glibc, libc and system calls.
- What is POSIX?
- Linux vs POSIX?
- What is a POSIX API?
- What is an API vs ABI?
- What is
errno? - How is
errnoimplemented? - Why should you not directly check
errnoafter every function? - What does
perror()do? - Difference between
perror()andstrerror().
2. Processes
This is one of the most important interview areas.
Process Basics
- What is a process?
- Process vs program?
- Process vs thread?
- What are the different process states?
- What is PID?
- What is PPID?
- What is process ID 1?
- What is a parent process?
- What is a child process?
- What is an orphan process?
- What is a zombie process?
- How does a process become zombie?
- How does the parent remove a zombie?
- What happens if the parent terminates before the child?
- Who adopts an orphan process?
- What is process hierarchy?
- How can you see process hierarchy in Linux?
- What is
ps? - What is
/proc/<pid>?
3. fork()
- What is
fork()? - What does
fork()return? - What happens internally during
fork()? - Does
fork()copy the entire process memory? - What is Copy-on-Write (COW)?
- Why is Copy-on-Write used?
- What happens to global variables after
fork()? - What happens to stack after
fork()? - What happens to heap after
fork()? - What happens to file descriptors after
fork()? - Does child inherit environment variables?
- Does child inherit signal handlers?
- Does child inherit pending signals?
- Does child inherit mutexes?
- What happens to threads after
fork()in a multithreaded process? - What is
fork()+exec()? - Why is
fork()commonly followed byexec()?
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:
- What does
exec()do? - Does
exec()create a new process? - Difference between
fork()andexec(). - Why is
exec()usually used withfork()? - Difference between
execv()andexecvp(). - What happens to PID after
exec()? - What happens to open file descriptors after
exec()? - What is
FD_CLOEXEC? - What happens to memory after
exec()? - What happens to signal dispositions after
exec()? - Why can
exec()fail? - Explain
fork() → exec() → wait().
5. Process Termination
exit()_exit()_Exit()- Difference between
exit()and_exit(). - What happens when
exit()is called? - What are
atexit()handlers? - What happens to stdio buffers?
- Why is
_exit()preferred in a child afterfork()in certain cases? - What is exit status?
- How does parent obtain child exit status?
6. wait() / waitpid()
- What is
wait()? - What is
waitpid()? - Difference between
wait()andwaitpid(). - What is
WIFEXITED()? - What is
WEXITSTATUS()? - What is
WIFSIGNALED()? - What is
WTERMSIG()? - What is
WIFSTOPPED()? - What is
WSTOPSIG()? - What is
WIFCONTINUED()? - What is blocking
wait()? - How do you perform non-blocking wait?
- How do you prevent zombie processes?
7. File Descriptors
This is extremely important for Linux interviews.
- What is a file descriptor?
- Why does Linux use file descriptors?
- What are standard file descriptors?
stdin = 0stdout = 1stderr = 2- What is a file descriptor table?
- What is an open file description?
- What is an inode?
- Explain relationship:
Process
↓
File Descriptor
↓
Open File Description
↓
Inode
↓
File
- What does
open()return? - What happens internally when
open()is called? - What happens when
close()is called? - What happens if you don’t close a file descriptor?
- What is FD leak?
- How do you detect FD leaks?
- What is the maximum number of FDs?
- What is
ulimit -n? - Difference between file descriptor and FILE pointer.
- Difference between
fdandFILE *.
8. File Operations
Know:
open()
close()
read()
write()
pread()
pwrite()
lseek()
fcntl()
ioctl()
dup()
dup2()
dup3()
Questions:
- Explain
open(). - Explain
read(). - Explain
write(). - Explain
close(). - What does
lseek()do? - What is
SEEK_SET? - What is
SEEK_CUR? - What is
SEEK_END? - Can
lseek()be used on a pipe? - What happens if
read()returns 0? - What does partial
read()mean? - What does partial
write()mean? - Why can
write()write fewer bytes than requested? - Difference between blocking and non-blocking I/O.
- What is
O_RDONLY? O_WRONLY?O_RDWR?O_CREAT?O_APPEND?O_TRUNC?O_EXCL?O_NONBLOCK?O_SYNC?O_DSYNC?O_CLOEXEC?
9. dup(), dup2(), dup3()
- What is
dup()? - What is
dup2()? - What is
dup3()? - Difference between
dup()anddup2(). - How does shell output redirection work?
Example:
./program > output.txt
- How can you implement:
command > file
using system calls?
Answer involves:
open()
dup2()
close()
exec()
10. File I/O vs Standard I/O
read()vsfread()write()vsfwrite()open()vsfopen()close()vsfclose()- What is stdio buffering?
- Full buffering?
- Line buffering?
- Unbuffered I/O?
- Why does
printf()not immediately write to terminal/file? - What does
fflush()do? - Why can output be duplicated after
fork()?
11. Pipes
- What is a pipe?
- How does pipe work?
- Is pipe unidirectional?
- What are anonymous pipes?
- What are named pipes?
- What is FIFO?
- Difference between pipe and FIFO.
- How is a pipe created?
- What does
pipe()return? - What happens when pipe buffer becomes full?
- What happens when no reader exists?
- What happens when no writer exists?
- What happens when all writers close the pipe?
- What does
read()return on EOF? - What happens when writing to a pipe with no reader?
- What is
SIGPIPE? - What is
PIPE_BUF? - Is pipe communication bidirectional?
- How can two processes communicate bidirectionally?
12. FIFO
- What is FIFO?
- Why is FIFO called named pipe?
- How do you create FIFO?
mkfifo()- FIFO vs regular file.
- FIFO vs anonymous pipe.
- Blocking behavior of FIFO.
- What happens when FIFO has no reader?
- 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:
- What is IPC?
- Why do processes need IPC?
- List Linux IPC mechanisms.
- Which IPC is fastest?
- Which IPC allows direct shared memory?
- Which IPC provides message boundaries?
- Which IPC is suitable for large data?
- Shared memory vs pipe.
- Message queue vs pipe.
- Semaphore vs mutex.
- Socket vs pipe.
14. Shared Memory
- What is shared memory?
- Why is shared memory fast?
- How do two processes share memory?
- What is
shmget()? shmat()?shmdt()?shmctl()?- POSIX shared memory?
shm_open()mmap()- Shared memory synchronization?
- Why does shared memory need synchronization?
- Shared memory vs message queue.
- Shared memory vs pipe.
- 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:
- What is message queue?
- Message queue vs pipe.
- Why use message queues?
- What is message priority?
- What happens when queue is full?
- Blocking vs non-blocking message queue.
- POSIX vs System V message queues.
16. Signals
Another must-know topic.
- What is a signal?
- Why are signals used?
- Synchronous vs asynchronous signals.
SIGINTSIGTERMSIGKILLSIGSTOPSIGSEGVSIGBUSSIGPIPESIGCHLDSIGALRMSIGUSR1SIGUSR2- What is signal handler?
signal()vssigaction().- Why prefer
sigaction()? - What is signal masking?
- What is
sigprocmask()? - What is
sigpending()? - What is
sigsuspend()? - What is
kill()? - Does
kill()always terminate a process? - What does
raise()do? - What is
pause()? - What is a blocked signal?
- What is a pending signal?
- Can
SIGKILLbe caught? - Can
SIGSTOPbe caught? - What happens when multiple signals arrive?
- What are real-time signals?
- Standard vs real-time signals.
- What is signal-safe function?
- What functions can safely be called from signal handlers?
17. Threads
- What is a thread?
- Process vs thread.
- Why use threads?
- User-level vs kernel-level threads.
- What is POSIX thread?
pthread_create()pthread_join()pthread_exit()pthread_self()pthread_cancel()- What happens if thread function returns?
- Joinable vs detached thread.
- What is a detached thread?
- What happens if main thread exits?
- Thread stack?
- Thread-local storage?
- What does each thread share?
- 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
- What is mutex?
- Why do we need mutex?
pthread_mutex_init()pthread_mutex_lock()pthread_mutex_unlock()pthread_mutex_destroy()- What is recursive mutex?
- Normal mutex?
- Error-checking mutex?
- Mutex vs semaphore.
- Mutex vs spinlock.
- What is deadlock?
- How does deadlock happen?
- How can deadlock be prevented?
- What is lock ordering?
19. Condition Variables
- What is condition variable?
- Why use condition variable?
pthread_cond_wait()pthread_cond_signal()pthread_cond_broadcast()- Why does
pthread_cond_wait()release mutex? - Why should condition variable be used with mutex?
- Why should
whilegenerally be used instead ofifaround condition waits? - What is spurious wakeup?
- Producer-consumer using condition variables.
20. Semaphores
- What is semaphore?
- Binary semaphore?
- Counting semaphore?
sem_init()sem_wait()sem_post()sem_trywait()sem_destroy()- Mutex vs semaphore.
- Binary semaphore vs mutex.
- Counting semaphore use cases.
- Can a different thread unlock a mutex?
- Can a different thread call
sem_post()?
21. Deadlock
Know the four Coffman conditions:
- Mutual exclusion
- Hold and wait
- No preemption
- 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
- What is race condition?
- Give an example.
- How do you reproduce race conditions?
- How do you prevent race conditions?
- Mutex solution.
- Atomic operation solution.
- Race condition vs data race.
- Why does
volatileNOT solve race conditions? - Atomic vs volatile.
23. Synchronization
Know:
Mutex
Semaphore
Condition Variable
Spinlock
Read/Write Lock
Atomic Operations
Memory Barriers
Futex
Questions:
- Mutex vs semaphore.
- Mutex vs spinlock.
- Spinlock vs rwlock.
- Atomic operation vs mutex.
- What is memory ordering?
- What is memory barrier?
- What is
futex()? - Why are futexes important in Linux?
24. Scheduling
- What is CPU scheduling?
- Preemptive scheduling?
- Cooperative scheduling?
- Process priority?
- Nice value?
nice()setpriority()- Real-time scheduling?
SCHED_FIFOSCHED_RRSCHED_OTHERSCHED_DEADLINE- What is priority inversion?
- Priority inheritance?
- Priority ceiling?
25. CPU Affinity
- What is CPU affinity?
- Why pin a thread/process to a CPU?
sched_setaffinity()sched_getaffinity()- Why is CPU affinity useful in real-time/embedded systems?
26. mmap()
Extremely important for Embedded Linux.
- What is
mmap()? - Why use
mmap()? - Memory mapping?
- File-backed mapping?
- Anonymous mapping?
MAP_SHAREDMAP_PRIVATEPROT_READPROT_WRITEPROT_EXECMAP_ANONYMOUSMAP_FIXEDmunmap()msync()mprotect()madvise()- mmap vs read/write.
- How can processes communicate using mmap?
- How does mmap relate to device drivers?
- Why do drivers expose
mmap()?
27. Virtual Memory
- What is virtual memory?
- Why does Linux use virtual memory?
- Virtual address vs physical address.
- Page?
- Page table?
- MMU?
- TLB?
- Page fault?
- Minor page fault?
- Major page fault?
- Demand paging?
- Copy-on-write?
- Anonymous memory?
- File-backed memory?
- Swap?
- What happens during page fault?
- What is memory fragmentation?
- Internal vs external fragmentation.
28. brk() and mmap() / Heap
- How does
malloc()obtain memory? - What is
brk()? - What is
sbrk()? - Does malloc always use
brk()? - When does malloc use
mmap()? - What happens when
free()is called? - What is heap fragmentation?
- What is memory leak?
- How can memory leaks be detected?
29. select()
- What is
select()? - Why use
select()? - What is I/O multiplexing?
- What is
fd_set? FD_ZERO()FD_SET()FD_CLR()FD_ISSET()- What is timeout?
- Limitations of
select(). - Why does
select()modifyfd_set? - What is
FD_SETSIZE?
30. poll()
- What is
poll()? pollfdstructure.POLLINPOLLOUTPOLLERRPOLLHUPPOLLNVALselect()vspoll().- Advantages of poll.
31. epoll()
Very important for advanced Linux interviews.
- What is epoll?
- Why was epoll introduced?
epoll_create1()epoll_ctl()epoll_wait()EPOLLINEPOLLOUTEPOLLERREPOLLHUP- Level-triggered epoll.
- Edge-triggered epoll.
- LT vs ET.
- Why must you use non-blocking I/O with ET?
EPOLLONESHOTEPOLLEXCLUSIVE- epoll vs select.
- epoll vs poll.
- How does epoll scale with thousands of FDs?
32. Non-Blocking I/O
- What is blocking I/O?
- What is non-blocking I/O?
O_NONBLOCK- What does
EAGAINmean? - What does
EWOULDBLOCKmean? - How do you implement non-blocking read?
- Non-blocking socket.
- Non-blocking pipe.
- Non-blocking device driver.
33. Sockets
This is a huge interview topic.
Basics
- What is socket?
- What is socket programming?
- TCP vs UDP.
- Client-server architecture.
- What is IP address?
- What is port?
- What is protocol?
- What is socket family?
AF_INETAF_INET6AF_UNIX
TCP
Know:
socket()
bind()
listen()
accept()
connect()
send()
recv()
close()
Questions:
- Explain TCP server flow.
- Explain TCP client flow.
- Why is
listen()required? - What does
accept()return? - Does
accept()create a new socket? - Difference between listening socket and connected socket.
- What is backlog?
- What happens if
accept()isn’t called? - What does
connect()do? - What happens when client closes connection?
- What does
recv()return 0 mean? - What is
SO_REUSEADDR? - What is
SO_REUSEPORT?
34. UDP
- TCP vs UDP.
- Is UDP connection-oriented?
- Does UDP guarantee delivery?
- Does UDP preserve message boundaries?
sendto()recvfrom()sendmsg()recvmsg()- UDP broadcast.
- UDP multicast.
35. Unix Domain Sockets
Especially useful in Embedded Linux / Android.
- What is Unix domain socket?
- Why use Unix sockets?
- Unix socket vs TCP socket.
AF_UNIX- Stream vs datagram Unix sockets.
- Abstract namespace sockets.
- How can processes communicate through Unix sockets?
36. Socket I/O Multiplexing
Questions:
- How can one server handle multiple clients?
- Threads vs select.
- Threads vs epoll.
- select + socket.
- poll + socket.
- epoll + socket.
- Non-blocking socket + epoll.
- Reactor pattern.
37. File System
- What is filesystem?
- What is inode?
- What is directory?
- What is hard link?
- What is symbolic link?
- Hard link vs soft link.
- What is mount?
- What is mount point?
- What is
/proc? - What is
/sys? - What is
/dev? - What is
/tmp? - What is
/etc? - What is
/var? - What is
/home? - What is
/run? - What is tmpfs?
- What is procfs?
- What is sysfs?
- What is devtmpfs?
38. Directory APIs
Know:
opendir()
readdir()
closedir()
rewinddir()
seekdir()
telldir()
Questions:
- How do you list directory contents from C?
- What does
readdir()return? - What is
struct dirent? - What is
d_name? - How do you recursively traverse a directory?
39. File Metadata
Know:
stat()
fstat()
lstat()
Questions:
- Difference between
stat()andlstat(). stat()vsfstat().- What is
struct stat? - File size?
- File permissions?
- File type?
- Access time?
- Modification time?
- Change time?
- What is
st_mode? - What is
S_ISREG()? S_ISDIR()?S_ISLNK()?
40. Permissions
- Linux file permissions.
- Owner/group/others.
rwx.- Numeric permissions.
chmod().chown().fchmod().umask().- What is umask?
- What happens when creating a file?
- SUID?
- SGID?
- Sticky bit?
- ACL?
- Capability?
41. Links
- Hard link?
- Soft link?
link()unlink()symlink()readlink()- Why can’t directories normally have hard links created by users?
- What happens when original file is deleted?
42. Daemons
- What is daemon?
- Foreground vs background process.
- How do you create daemon?
- What is daemonization?
- Why call
fork()? - Why call
setsid()? - Why change working directory?
- Why redirect stdin/stdout/stderr?
- Why close inherited FDs?
- What is a session?
- What is process group?
- What is controlling terminal?
43. Sessions & Process Groups
- What is process group?
- What is process group ID?
- What is session?
- What is session leader?
- What is controlling terminal?
setsid()setpgid()getsid()getpgrp()- Why are process groups needed for job control?
44. Terminal / TTY
- What is TTY?
- What is pseudo-terminal?
- PTY vs TTY.
- What is
/dev/tty? /dev/pts?- What is terminal driver?
- What is terminal line discipline?
- What is canonical mode?
- What is raw mode?
termios.
45. Memory Management
malloc()calloc()realloc()free()memset()memcpy()memmove()memcmp()- Memory leak.
- Double free.
- Use-after-free.
- Buffer overflow.
- Dangling pointer.
- Heap corruption.
- Stack overflow.
- Memory alignment.
- Memory fragmentation.
- How do you debug memory corruption?
46. memcpy() vs memmove()
- Difference?
- What happens with overlapping memory?
- Why can
memcpy()fail with overlapping regions? - Implementation-level difference.
47. Memory Alignment
- What is alignment?
- Why is alignment important?
- Aligned vs unaligned access.
- ARM alignment behavior.
- Structure alignment.
- Padding.
posix_memalign()aligned_alloc().
48. ioctl()
Especially important for device-driver interviews.
- What is ioctl?
- Why use ioctl?
- Why can’t normal
read/writehandle everything? - How does ioctl work?
- What is ioctl command number?
_IO()_IOR()_IOW()_IOWR()- What is direction?
- What is command magic number?
- What is command number?
- How does userspace communicate with driver through ioctl?
- Why must kernel validate user pointers?
copy_to_user()copy_from_user().
49. fcntl()
- What is
fcntl()? - File descriptor duplication.
- File descriptor flags.
- File status flags.
F_GETFDF_SETFDF_GETFLF_SETFLFD_CLOEXEC- File locking with
fcntl().
50. File Locking
- What is file locking?
- Advisory locking?
- Mandatory locking?
flock()fcntl()locking.- Shared lock?
- Exclusive lock?
- Blocking vs non-blocking lock.
51. Timers
Know:
sleep()
usleep()
nanosleep()
alarm()
setitimer()
timer_create()
timer_settime()
timerfd_create()
Questions:
sleep()vsnanosleep().- Why is
usleep()obsolete? - What is POSIX timer?
- What is timerfd?
- Timer vs sleep.
- Periodic timer?
- Absolute vs relative timer.
CLOCK_MONOTONICvsCLOCK_REALTIME.
52. Time APIs
time()gettimeofday()clock_gettime()clock_settime()CLOCK_REALTIMECLOCK_MONOTONICCLOCK_MONOTONIC_RAWCLOCK_PROCESS_CPUTIME_IDCLOCK_THREAD_CPUTIME_ID
Very common:
Why should timeout logic generally use CLOCK_MONOTONIC instead of CLOCK_REALTIME?
53. /proc
Extremely important in Linux.
- What is proc filesystem?
- Why is
/proccalled virtual filesystem? /proc/cpuinfo/proc/meminfo/proc/interrupts/proc/ioports/proc/iomem/proc/mounts/proc/modules/proc/<pid>/status/proc/<pid>/maps/proc/<pid>/fd/proc/<pid>/cmdline/proc/<pid>/stat/proc/loadavg
54. /sys / sysfs
- What is sysfs?
- Difference between
/procand/sys. - What is kobject?
- What is sysfs attribute?
- What is
/sys/class? - What is
/sys/devices? - What is
/sys/bus? - How do drivers expose information through sysfs?
55. Environment Variables
- What is environment variable?
getenv()setenv()unsetenv()putenv()- How does child inherit environment?
- How does
execve()handle environment?
56. Dynamic Linking
- Static linking vs dynamic linking.
- What is shared library?
.sofile?.afile?- What is ELF?
- What is dynamic linker?
- What is
ld.so? - What is
LD_LIBRARY_PATH? - What is RPATH?
- What is RUNPATH?
- What is symbol resolution?
- What is lazy binding?
- What is PLT?
- What is GOT?
- What is
dlopen()? dlsym()dlclose()dlerror().
57. ELF
- What is ELF?
- ELF header?
- Program header?
- Section header?
.text.data.bss.rodata- Symbol table.
- Relocation.
- Static vs dynamic ELF.
readelf.objdump.nm.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:
- What is strace?
- How does strace work?
- How do you trace child processes?
- How do you trace file operations?
- How do you trace network calls?
- What is
ptrace()? - 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:
- How do you debug segmentation fault?
- What is core dump?
- How do you enable core dump?
- What is
ulimit -c? - How do you analyze core dump?
- What is GDB?
- Attach GDB to running process?
- Debug multithreaded application?
- Debug deadlock?
- Debug memory corruption?
60. Core Dump
- What is core dump?
- Why is core dump generated?
- How to enable core dump?
- What is
ulimit -c unlimited? - How do you analyze core?
- What information does core contain?
- What is a segmentation fault?
- SIGSEGV vs SIGBUS.
61. Linux IPC – Advanced
Know:
eventfd
signalfd
timerfd
memfd
pidfd
futex
Questions:
- What is eventfd?
- Why use eventfd?
- eventfd vs pipe.
- What is signalfd?
- Why use signalfd?
- What is timerfd?
- Why combine timerfd with epoll?
- What is pidfd?
- Why is pidfd useful?
- What is futex?
- How does pthread mutex relate to futex?
62. Asynchronous I/O
- What is asynchronous I/O?
- Synchronous vs asynchronous I/O.
- POSIX AIO.
aio_read()aio_write()io_uring.- What is io_uring?
- Why was io_uring introduced?
- io_uring vs epoll.
- Blocking vs non-blocking vs asynchronous I/O.
63. io_uring
For modern Linux interviews:
- What is io_uring?
- Submission Queue?
- Completion Queue?
- SQE?
- CQE?
- Why can io_uring reduce syscall overhead?
- io_uring vs epoll.
64. Namespaces
Important for modern Linux.
- What is Linux namespace?
- Why are namespaces used?
- PID namespace.
- Mount namespace.
- Network namespace.
- IPC namespace.
- UTS namespace.
- User namespace.
- Cgroup namespace.
- Time namespace.
65. Cgroups
- What are cgroups?
- Why use cgroups?
- CPU limits.
- Memory limits.
- I/O limits.
- Process accounting.
- cgroups vs namespaces.
- How containers use cgroups.
66. Containers
- What is Linux container?
- Container vs VM.
- How do namespaces provide isolation?
- How do cgroups provide resource control?
- What is Docker fundamentally using from Linux?
67. Capabilities
- What are Linux capabilities?
- Why capabilities?
- Root vs capabilities.
CAP_NET_ADMINCAP_SYS_ADMINCAP_SYS_PTRACE- Effective capabilities.
- Permitted capabilities.
- Inheritable capabilities.
68. Security
- File permissions.
- ACL.
- Capabilities.
- SELinux.
- AppArmor.
- ASLR.
- NX bit.
- Stack canary.
- PIE.
- RELRO.
69. Boot & Process Startup
For Embedded Linux, know:
Boot ROM
↓
Bootloader
↓
Linux Kernel
↓
init
↓
systemd / init system
↓
Services
↓
Application
Questions:
- What happens after kernel boot?
- What is init?
- Why is PID 1 special?
- What is systemd?
- What is service?
- What is daemon?
- How does systemd start services?
- What is target?
- What is unit?
- What is journal?
70. Linux Logging
syslog()openlog()closelog()logger- journald.
journalctl.- Kernel logs vs application logs.
dmesg.- 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:
- How does userspace communicate with kernel?
- ioctl vs sysfs.
- sysfs vs procfs.
- debugfs?
- What is netlink?
- Why use mmap in drivers?
- How does
/devcommunicate with drivers? - What happens when userspace opens
/dev/mydevice?
72. Device Files
- What is
/dev? - Character device vs block device.
- What is major number?
- What is minor number?
- What is
mknod()? - What is
udev? - How are device nodes created?
- What happens during:
open("/dev/mydevice", ...);
- How does VFS reach driver?
- What is
file_operations?
73. VFS
- What is VFS?
- Why does Linux need VFS?
- What is inode?
- What is dentry?
- What is
struct file? - What is superblock?
- What is filesystem object?
- Explain:
Application
↓
System Call
↓
VFS
↓
Filesystem
↓
Block Layer
↓
Device Driver
↓
Hardware
- Difference between inode and
struct file. - 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:
- How do you find CPU bottleneck?
- How do you find memory bottleneck?
- How do you find I/O bottleneck?
- How do you identify high CPU process?
- How do you identify memory leak?
- How do you identify FD leak?
- How do you identify thread problems?
- How do you profile an application?
75. perf
- What is perf?
- CPU profiling.
perf statperf recordperf report- CPU cycles.
- Instructions.
- Cache misses.
- Context switches.
- Page faults.
76. ftrace
- What is ftrace?
- Function tracer.
- Function graph tracer.
- Tracepoints.
- kprobes.
- uprobes.
- How is ftrace different from strace?
- 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:
- What is page cache?
- Buffered I/O?
- Direct I/O?
O_DIRECT?O_SYNC?fsync()?fdatasync()?sync()?- Why is
write()not necessarily writing directly to disk? - What happens when
fsync()is called?
78. System Call Internals
For senior interviews:
- How does a system call work internally?
- What is syscall number?
- What happens during syscall entry?
- What happens during syscall return?
- What is
syscallinstruction? - What is
sysenter? - ARM
SVCinstruction? - x86 syscall mechanism?
- How are syscall arguments passed?
- What is syscall table?
- 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:
- Difference between
EINTRandEAGAIN. - What should you do if
read()returnsEINTR? - What is
EMFILE? EMFILEvsENFILE.- What is
EPIPE? - Why can
write()returnEPIPE? - What is
ECONNRESET? - 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 -L → perf → 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:
- What is a system call?
- User space vs kernel space?
- Process vs thread?
fork()?- Copy-on-write?
exec()?fork()vsexec()?wait()vswaitpid()?- Zombie vs orphan?
- File descriptor?
- File descriptor table?
- inode vs file descriptor?
open/read/write/close?dup2()?fcntl()?- Pipe?
- FIFO?
- Shared memory?
- Message queue?
- Semaphore?
- Signal?
sigaction()?- Signal masking?
- Mutex?
- Condition variable?
- Mutex vs semaphore?
- Race condition?
- Deadlock?
- Priority inversion?
mmap()?- Virtual memory?
- Page fault?
select()?poll()?epoll()?- LT vs ET?
- Blocking vs non-blocking I/O?
- TCP socket programming?
- TCP vs UDP?
- Unix domain socket?
/proc?/sys?ioctl()?- VFS?
- Device file?
strace?- GDB/core dump?
perf?- Dynamic linking/ELF?
- 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

Leave a Reply