Skip to content

Instantly share code, notes, and snippets.

@ravikant-pal
Created July 12, 2025 08:55
Show Gist options
  • Save ravikant-pal/4f5ffbd4f3f2d5594dbe2d8d4c964ada to your computer and use it in GitHub Desktop.
Save ravikant-pal/4f5ffbd4f3f2d5594dbe2d8d4c964ada to your computer and use it in GitHub Desktop.
Kill Zombie Challenge

πŸ§Ÿβ€β™‚οΈ Kill the Zombie β€” Linux Process Challenge

Welcome to your 20-minute Linux shell mini-challenge!

🎯 Goal

Learn to:

  • Launch background jobs (fake zombie-like processes)
  • Identify and monitor running processes
  • Kill them using kill, killall, or pkill
  • Observe real CPU/MEM changes via top

πŸ›  How to Start

  1. Give executable permission to both scripts:

    chmod +x spawn_zombies.sh monitor_top.sh
  2. Run the zombie spawner:

    ./spawn_zombies.sh
  3. Open a new terminal tab and monitor system resources:

    top
  4. After attempting cleanup, run the monitor to compare system load:

    ./monitor_top.sh

βœ… Your Task

  • Locate processes using:

    ps aux | grep sleep
    top
    htop
  • Kill them using:

    kill <PID>
    killall yes
    pkill tail
  • Observe the drop in CPU/memory usage in top


πŸ“Œ Bonus Challenges

  • Can you killall all dummy jobs in one command?
  • What’s the PID of the infinite while loop?
  • Which process consumed the most CPU?
  • What happens if you don’t & (background) a job?

πŸ’‘ Useful Commands

Command Description
jobs -l Show running background jobs
ps aux List all system processes
kill <PID> Kill a process by PID
killall <name> Kill all processes by name
top / htop Monitor system resource usage live
pkill <name> Kill process by name using pattern

🏁 Wrap-Up

This challenge simulates how we handle rogue or resource-hogging processes in production. You'll use these skills often when:

  • Restarting broken services
  • Automating cleanup tasks
  • Managing cron jobs and daemons
  • Debugging memory leaks and CPU spikes

✨ Bonus Tip: Always be cautious with kill -9. It's like the nuclear option. 🧨


Happy hunting! Let’s terminate those zombies! πŸ§Ÿβ€β™€οΈπŸ’»

#!/bin/bash
# monitor_top.sh - Snapshot system resource usage before & after challenge
echo "πŸ“Š CPU & Memory Snapshot BEFORE:"
top -b -n1 | head -15
echo -e "\\n⏳ Wait 10 seconds while you kill dummy jobs...\n"
sleep 10
echo "πŸ“Š CPU & Memory Snapshot AFTER:"
top -b -n1 | head -15
#!/bin/bash
# πŸ§Ÿβ€β™‚οΈ spawn_zombies.sh - Simulate zombie-like jobs for kill practice
echo "πŸš€ Launching dummy background jobs..."
sleep 9999 &
yes > /dev/null &
tail -f /dev/null &
while true; do echo \"Still alive...\"; sleep 10; done &
echo "βœ… 4 background jobs started:"
jobs -l
echo -e "\\n🧠 Challenge:"
echo "1. Use ps/top/htop to find all spawned zombie-like processes."
echo "2. Kill them individually or all together."
echo "3. Use 'top' to check CPU & memory before and after."
echo -e "\\nπŸ’‘ Hints:"
echo "- Use 'ps aux | grep <pattern>'"
echo "- Use 'kill <PID>' or 'killall <name>'"
echo "- Watch top or htop side-by-side."
echo -e "\\n⚠️ Cleanup Reminder:"
echo "If you don't kill them, they will keep running until logout!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment