📌 Explaining Linux System Calls: Fork and Exec Made Easy with a Big Fat Indian Wedding 📌

Prashant Lakhera
2 min readMay 10, 2024

Anyone understanding Linux must know two essential system calls:
✅ fork
✅ exec.
I’ve found that beginners often struggle to grasp these concepts. So, this is my attempt to explain these calls using the example of a big fat Indian wedding.

🍴 Fork in an Indian Wedding Scenario
Imagine you are the main wedding organizer (you’re like the original program on a computer). You’re responsible for everything from decorations to catering. As the event starts, you realize you need to handle a specific task, let’s say managing the arrival of guests, which requires constant attention.
To handle this without neglecting your other duties, you delegate the guest management task to a trusted assistant. This is similar to the fork() system call:
✔️You continue overseeing the entire wedding.
✔️ Your assistant (like the child process created by fork()) takes over the guest management, operating as an independent manager but initially having the same instructions or knowledge as you.

📱 Exec in an Indian Wedding Scenario
Now, your assistant, who has been tasked with managing the guests, has decided to focus solely on this new role. Instead of just following your general instructions, they adopt a specific method or tool, like using a guest list app on a tablet to check in guests. This shift from general duties to a particular task is like the exec() system call:
✔️ Your assistant completely stops any other general tasks and transforms into a specialized guest manager, using specific tools and methods suited only for guest management.

🔄 Combining Fork and Exec: Scenario with ls
Let’s say, during the wedding, you also need to check the inventory of supplies quickly (similar to running the ls command on a computer). Here’s how you would use both fork() and exec():

✔️ Fork: You ask another assistant to handle the inventory check so that the main tasks of the wedding are not interrupted.
✔️ Exec: This assistant then exclusively focuses on checking the inventory, perhaps using a specific inventory management software or system, forgetting all other duties, and concentrating only on this task.

🏁 This scenario allows the wedding to proceed smoothly with various tasks handled simultaneously, without disrupting the main flow of events, just as fork() and exec() enable a computer to handle multiple tasks efficiently.

📚 If you’re interested in more in-depth explanation of these topics, please check out my new book “Cracking the DevOps Interview”

📚 To learn more about AWS, check out my book “AWS for System Administrators”

🌈 Image ref: https://lnkd.in/gTzVh_37



Prashant Lakhera

AWS Community Builder, Ex-Redhat, Author, Blogger, YouTuber, RHCA, RHCDS, RHCE, Docker Certified,4XAWS, CCNA, MCP, Certified Jenkins, Terraform Certified, 1XGCP