BM: Baca dalam Bahasa Melayu
World L2: Keys & Staff
Signals, kill and jobs
You will learn: to stop a program politely or firmly, and to run long jobs in the background.
Checked with Linux (Debian 13) on 1 Nov 2026
The problem
The oven timer script is stuck in a loop. It runs outside your terminal, so Ctrl+C cannot reach it. How do you stop it?
Pick one answer.
Watch
You are you in /home/you. 1 things here. Services: cron running, ssh running, nginx running.
you@kedai:~$Folder ~
- bin/ (folder)
drwxrwxr-xoven-timer.sh
+ 3 hidden (ls -a)
Services
cronrunningstarts at bootsshrunningstarts at bootnginxrunningstarts at boot
Busy programs
1241bash /home/you/bin/oven-timer.shusing the CPU
pkill sent a signal: A message to a process: TERM asks it to stop, KILL (9) stops it at once, Ctrl+C sends INT. called TERM: “please stop”. This script ignores it, so pgrep still finds PID 1241. Watch the busy list.
Check
Stopping a program is a ladder: polite first, firm last. Put the steps in order.
First step at the top. Put these in order. Use the arrows, or drag.
- Ctrl+C, if it holds your terminal
- Wait a few seconds, then check with pgrep
- kill PID: the polite TERM signal
- kill -9 PID: KILL, the last resort
Try it
The polite way failed. Use the last resort: kill -9. Stop the oven timer for good.
You are you in /home/you. 1 things here. Services: cron running, ssh running, nginx running.
you@kedai:~$Folder ~
- bin/ (folder)
drwxrwxr-xoven-timer.sh
+ 3 hidden (ls -a)
Services
cronrunningstarts at bootsshrunningstarts at bootnginxrunningstarts at boot
Busy programs
1241bash /home/you/bin/oven-timer.shusing the CPU
Hint
-9 is the KILL signal. The program cannot ignore it.Predict
Why not always start with kill -9?
Pick one answer.
Try it
A long job need not block you. Start one in the background with &: sleep 300 &. Then type jobs.
You are you in /home/you. 0 things here. Services: cron running, ssh running, nginx running.
you@kedai:~$Folder ~
Empty folder
+ 3 hidden (ls -a)
Services
cronrunningstarts at bootsshrunningstarts at bootnginxrunningstarts at boot
Hint
A job is a program this terminal started.& sends it to the back.Check
Does the program hold your terminal (front), or let you type (back)?
Drag a card into a box. Or tap the card, then tap the box.
You did it!
You can now stop programs politely or firmly, and juggle jobs.
Go deeper (optional)
Signals have numbers. 15 is TERM, kill’s default. 9 is KILL. Ctrl+C sends 2, INT. kill %1 stops job 1. Work that must run all day belongs in a service: lesson 8.
Real rep (optional), on your own Linux:
Real mission
sleep 100bgjobskill %1
0 of 5 steps done · Your ticks are saved.
Bahasa Melayu
Skrip pemasa ketuhar tersangkut dalam gelung. Ia berjalan di luar terminal anda, jadi Ctrl+C tak sampai kepadanya. Macam mana nak hentikan?
pkill hantar signal (isyarat) bernama TERM: “tolong berhenti”. Skrip ini abaikannya, jadi pgrep masih jumpa PID 1241. Tengok senarai program sibuk.
Hentikan program ialah satu tangga: sopan dulu, tegas akhir sekali. Susun langkahnya.
Cara sopan gagal. Guna jalan terakhir: kill -9. Hentikan pemasa ketuhar itu terus.
-9 ialah isyarat KILL. Program tak boleh abaikannya.Kenapa tak terus guna kill -9 setiap kali?
Kerja panjang tak perlu menghalang anda. Mulakan satu di belakang dengan &: sleep 300 &. Kemudian taip jobs.
& hantar ia ke belakang.Adakah program itu pegang terminal anda (depan), atau biar anda menaip (belakang)?
Kini anda boleh hentikan program dengan sopan atau tegas, dan urus job.
You finished this before. Practice is always welcome!
Official docs: kill (Debian 13 man page) · pkill (Debian 13 man page) · signal(7): the list of signals · Bash manual: Job Control Basics
You've learned for 25 minutes. A short break helps your brain.
Sprint done! Great focus. Stretch for a minute?