الفلاتر
طريقة البحث
  • الكلمات العادية تجد الأسماء والنصوص والأمثلة.
  • "كلمتان" تجد العبارة بالضبط.
  • --name أو -x تجد خيارًا.
  • #كلمة تبحث داخل الأوامر فقط.
  • @grep تجد الدروس والمعامل التي تستخدم grep.
  • الفلاتر: cat:network · in:labs · level:rhcsa · ch:8 · root:yes. ضع ! قبل كلمة لاستبعادها. OR بين الكلمات تعني إحداها.
  • ↑ ↓ للتنقل · Enter للفتح · Esc للإغلاق · / للبحث

kill

Send a signal to processes by PID (or job number) — by default SIGTERM, a polite request to stop.

المستوى
امتحان RHCSA
المجموعة
العمليات والمهام
يحتاج root
للتغييرات
الحزمة
util-linux / bash (built-in)

هذا الجزء لم يُترجم بعد. أنت ترى النص الإنجليزي.

ماذا يفعل

kill PID sends SIGTERM (15): the program can save its data and exit. If it does not react, kill -9 PID (SIGKILL) makes the kernel end it at once — without cleanup. Other signals do other things: SIGHUP (1) makes many daemons re-read their config, SIGSTOP/SIGCONT pause and continue.

Users can only signal their own processes; root can signal all. In bash, kill is a built-in that also accepts job numbers like %1.

طريقة الكتابة

kill [-s SIGNAL | -SIGNAL] PID...
kill -l [NUMBER] | -L

الأجزاء الرئيسية

1 HUP
Hang up; daemons often reload the config.
2 INT
Interrupt (Ctrl+C).
3 QUIT
Quit with a core dump.
9 KILL
Kill now; cannot be caught.
15 TERM
Terminate politely (default).
18 CONT
Continue a paused process.
19 STOP
Pause; cannot be caught.
20 TSTP
Pause from the terminal (Ctrl+Z).
10 USR1, 12 USR2
Program-specific (like reopen logs).
-1 (PID)
All processes you may signal (dangerous).
-PGID
A negative PID = the whole process group.

الخيارات 8

الأكثر استخدامًا

-s, --signal SIGNAL
The signal (name or number).
-SIGNAL
Short form: -9, -KILL, -SIGKILL.
-l, --list [NUMBER]
List the signal names (or the name of a number).
-L, --table
List names and numbers as a table.
-q, --queue VALUE
Send the signal with a value (sigqueue).
-p, --pid
Only print the PIDs (util-linux kill, with a name).
-a, --all
Also match processes of other users by name (util-linux kill).
--timeout MS SIGNAL
Send a second signal if the process still runs after the time (util-linux kill).

أمثلة 11

$ مستخدم عادي# بصلاحية root (أو مع sudo)

  1. 1Stop a process politely

    kill 4123

    SIGTERM: the program can clean up.

  2. 2Force it

    kill -9 4123

    Only when SIGTERM did not work after some seconds.

  3. 3Reload a daemon's config

    kill -HUP $(cat /run/sshd.pid)

    On RHEL systemctl reload sshd does the same.

  4. 4List the signals

    kill -l

    Names and numbers.

  5. 5Stop a background job

    kill %2

    Job number from jobs.

  6. 6Pause and continue a process

    kill -STOP 4123; kill -CONT 4123

    Pause a heavy job for a while.

  7. 7Polite, then hard after a timeout

    /usr/bin/kill --timeout 5000 KILL -TERM 4123

    util-linux kill: SIGKILL if it still runs after 5 seconds.

  8. 8Stop a whole pipeline (process group)

    kill -TERM -4120

    Negative number = process group.

  9. 9Contain a suspicious process (security)

    kill -STOP 6666
    ls -l /proc/6666/exe; cat /proc/6666/cmdline | tr '\0' ' '

    Pause it, look at it, then decide; a killed process loses evidence in memory.

  10. 10Check if a process is still alive

    kill -0 4123 && echo "running"

    Signal 0 sends nothing; it only tests.

  11. 11Make a service reopen its log files

    kill -USR1 $(pidof nginx)

    nginx reopens logs on USR1 (log rotation).

انتبه

  • kill -9 can leave broken files, lock files and shared memory. Use it last.
  • Processes in state D (disk wait) do not die even with -9 until the I/O ends.

رموز الخروج

0 :: The signal was sent. 1 :: Error (no such process or not allowed).

الدليل الكامل

هذه الصفحة تشرح الأمر بكلمات بسيطة. الدليل الأصلي فيه كل التفاصيل.

في الطرفية: man kill