kill
asking a process to stopDespite the name, kill only delivers a signal to a process ID. The default, SIGTERM, asks the program to clean up and exit, and a well-written program does. SIGKILL is different: the kernel removes the process without telling it, so nothing gets saved or closed.
Ask with TERM first, and reach for KILL only when asking has failed.
At the terminal
Read the session first, then the notes: each numbered line in the output is answered by the note with the same number.
What the numbered lines are telling you
kill printed nothing; ps finds no process 4120. The program received SIGTERM, shut down cleanly and exited.
Process 4188 is still listed after a plain kill. It is stuck, or it handles SIGTERM and chose to carry on.
SIGKILL is acted on by the kernel, not the program. It always works, and the process gets no chance to flush files or release locks.
kill -l lists them. SIGHUP (1) traditionally means "reload your configuration"; SIGINT (2) is what Ctrl+C sends.
Switches
A switch changes how the command behaves. These are the ones used day to day; man kill lists the rest. Single-letter switches can usually be joined, so -l -a may be written -la.
-l- List every signal name and its number.
-15- SIGTERM, the default: ask the process to shut down cleanly. Also written -TERM.
-9- SIGKILL: stop the process at once, with no chance to clean up. Also written -KILL.
-1- SIGHUP: for many services, re-read the configuration. Also written -HUP.
-STOP- Pause the process. -CONT resumes it.
Variations worth knowing
The same tool, pointed at a narrower question. These four cover most of what it is reached for day to day.
kill -HUP 1042Asks a daemon to re-read its configuration without stopping.
pkill -f "node server.js"Signals every process whose command line matches, without looking up PIDs.
kill -STOP 4120 && kill -CONT 4120Freezes a process and later lets it continue.
kill -0 4120 && echo aliveSignal 0 sends nothing: it only tests whether the process exists and you may signal it.
In cybersecurity
A signal is the bluntest control there is over a running program, which is why who may send one is tightly restricted.
A database killed mid-write has no chance to finish. Use the service manager or SIGTERM and wait before escalating.
Stopping the logging or monitoring agent is an early step in many intrusions. Alert when those processes disappear.
A PID noted a minute ago may now belong to another process. Check with ps immediately before sending a signal as root.