Introduction
In the day to day of a system manager or an advanced Linux user, it is common to find processes that consume too many resources, are blocked or simply no longer necessary. In these cases, the most direct and secure way to stop them is by commandkillwhich allows a signal to be sent to a process identified by its identification number (PID). This article explains what a PID is, how the kill command works, what signals exist and offers practical examples so that you can apply this knowledge immediately and safely.
What is a process and your PID
In Linux, each running program is represented as a process. The kernel assigns to each process a unique identifier called PID (Process ID). This number allows the system and user to refer to a specific process without ambiguities. You can see the list of active processes with commands likeps auxortop, where the PID appears in the first column. Knowing the PID is the first step in being able to interact with the process, whether to pause it, resume it or finish it.
The kill command
The basic syntax ofkillis:
kill [opciones]
If no signal is specified,killsend by default the SIGTERM (15) signal, which requests the process to end in an orderly manner, releasing resources and saving its state if it is scheduled to do so. If the process ignores SIGTERM, you can climb to stronger signals, such as SIGKILL (9), which forces the kernel to finish the process immediately without the possibility of capture or cleaning.
Most commonly used signs
- SIGTERM (15): friendly termination request.
- SIGKILL (9): forced termination cannot be ignored.
- SINGENT (2): simulates the interruption with Ctrl + C.
- SIGSTOP (19): pause the process (can be resumed with SIGCONT).
- SIGCONT (18): resume a detention process.
You can specify the signal either by number or by name (prefix with-). For example,kill -9 1234orkill -SIGKILL 1234have the same effect.
How to find the PID of a process
Before usekillYou need to know the PID. Some usual forms are:
ps aux | grep nombre_del_proceso: filters the list of processes.pgrep -f patrón: directly returns the PID that matches the pattern.pidof nombre_del_programa: useful when you know the exact name of the executable.toporhtop: interactive interfaces showing the PID in real time.
Combine these tools withkillallows to create shortcuts, askill $(pgrep -f firefox)to finish all instances of Firefox.
Practical examples
- Finish a process you know your PID:
kill 5678 - Forging termination with SIGKILL:
kill -9 5678 - Send an interruption signal as if the user pressed Ctrl + C:
kill -2 5678 - Pause a process and then take it back:
kill -STOP 5678followed bykill -CONT 5678 - Finish all processes of a user:
kill -9 -u usuario(requires privileges).
Precautions and good practices
Althoughkillis powerful, its misuse can cause system instability or data loss. It is recommended that:
- Try SIGTERM first before using SIGKILL.
- Verify that the PID corresponds to the correct process (it avoids confusing similar numbers).
- Use
sudoonly when necessary to complete processes of other users or of the system. - In production servers, consider using control scripts or service management systems (systemd, supervision) rather than killing processes manually.
Conclusion
The commandkillis an essential tool in the arsenal of any Linux user. Understanding how it works, what signals exist and how to locate the PID of a process allows you to manage the system effectively and safely. With the examples and good practices presented in this article, you will be prepared to finish PID processes without jeopardizing the stability of your environment.


