How Computer Programs Run on Linux
How Computer Programs Run on Linux
What's a Computer Program?
Think of a program like a recipe. When you "run" it, the computer follows the instructions step by step. On Linux, we call this running recipe a process.
Real Life Examples
- Web browser (like Firefox)
- Game (like Minecraft)
- Text editor (like Notepad)
The Life of a Program
- ๐ฅ Loading: Computer copies the program from storage to memory
- ๐ Running: Computer follows the program's instructions
- ๐ Stopping: Program finishes or gets canceled
Program Settings (Environment Variables)
These are like special notes the program reads before starting:
LANG=en_US
- Sets language to EnglishHOME=/users/bob
- Shows where your files are stored
How Programs Talk to the Computer
Programs use special requests called system calls:
- ๐
read
- Read a file - ✏️
write
- Save changes - ๐ช
open
- Access a device
Emergency Signals
Like a walkie-talkie for programs:
- ๐จ Ctrl+C = "Stop immediately!" (SIGINT)
- ๐ฅ "Terminate now!" (SIGKILL)
Sharing Between Programs
Programs can share memory like a shared notebook:
- Create shared space (shmget)
- Connect to it (shmat)
- Write/read messages
- Disconnect when done (shmdt)
Common Questions
Why do some programs become zombies?
When programs finish but aren't cleaned up properly - use the wait
command to fix!
How to see what a program is doing?
Use strace
- it's like X-ray glasses for programs!
Can programs share secrets?
Yes! That's why we have special security like ASLR (memory scrambling).
Best Tips
- ๐ Always check program permissions
- ๐งน Clean up finished programs
- ๐ Use
strace
to find problems
Comments
Post a Comment