Linux for Developers
/Intermediate
Foreground & Background Processes
Definition
The concept of process control. A foreground process locks the terminal until it finishes. A background process runs invisibly, returning control of the terminal to the user immediately.
Explain Like I'm New
Foreground is cooking on the stove (you have to stand there and stir). Background is putting food in the slow cooker (you walk away and do other chores while it cooks).
Real World Example
If you type `sleep 100`, your terminal freezes for 100 seconds (Foreground). If you append an ampersand and type `sleep 100 &`, the computer immediately gives you a new prompt while the timer ticks away invisibly (Background).
Common Use Cases
- •Running web servers from the terminal
- •Non-blocking automation
Interview Questions
basic
- What keyboard shortcut will instantly pause a Foreground process so you can move it to the background?
intermediate
- If you start a long-running script in the background (`./script.sh &`) and then close your terminal window, does the script keep running?