Introduction
In the Linux environment, managing running processes is a daily task for system managers, developers and advanced users. Sometimes it is necessary to stop a program that has been hung, which consumes too many resources or is simply no longer needed. While the commandkillallows to finish processes by specifying your identifier (PID), there is a more direct alternative when the process name is known:killall. This article explains in detail how killall works, its syntax, the most useful options and some practical examples to use it safely and efficiently.
What is killall?
killall is a utility that belongs to the packagepsmiscin most Linux distributions. Its main function is to send a signal to all processes whose name exactly matches the argument provided. Unlike kill, which acts on a specific PID, killall acts on all processes that share the same name, which can be very practical when you have several instances of the same program running.
Basic syntax
The simplest way to use killall is:
killall nombre_del_proceso
This command will send the signalSIGTERM(number 15) to all processes whose name is exactlynombre_del_proceso. If the process does not respond to SIGTERM, it can be climbed to a stronger signal likeSIGKILL(number 9) using the option-sor--signal.
Useful options
-s SIGNALor--signal=SIGNAL: specifies the signal to be sent. For example,-s SIGKILLor-9.-ior--interactive: ask for confirmation before killing each process.-vor--verbose: shows information on the processes being completed.-eor--exact: requires an exact name match (by default killall ignores capital / lower case differences and allows partial coincidences up to a certain length).-gor--process-group: kills the whole group of processes rather than just individual processes.-ror--regexp: interprets the name as a regular expression.-u usuarioor--user=usuario: limits action to processes belonging to a particular user.
Practical examples
Imagine that you have several Firefox browser windows hanging and want to close them all:
killall firefox
If you want to see which processes will be affected before acting, combine the option-v:
killall -v firefox
To force immediate termination, send SIGKILL:
killall -s SIGKILL firefox
or its abbreviated form:
killall -9 firefox
If you just want to kill the Firefox processes that belong to the userjuan:
killall -u juan firefox
In case you need to match a pattern, for example finish all processes that start withchrome(aschrome, chrome-sandbox), you can use the regular expression option:
killall -r '^chrome.*'
Finally, if you prefer the system to ask you before killing each process, use the interactive mode:
killall -i firefox
Precautions and good practices
Although killall is very comfortable, its indiscriminate use may cause unwanted effects. Take into account the following points:
- Check the exact name of the process. A typographic error could end critical processes of the system.
- Use the option
-eto demand exact coincidence when there is a risk of confusion with similar names. - You'd rather send first
SIGTERMand wait a few seconds before resorting toSIGKILL. This allows processes to release resources and keep their state. - In production systems, consider using
pkillwith more specific filters or review the list of processes withpsbefore you run killall. - If you are in a multi-user environment, limit action with the option
-uto avoid affecting other users.
Conclusion
The commandkillallis a powerful and simple tool to finish Linux processes by name. Knowing your syntax, your options and best practices, you can efficiently manage your system processes without the need to search for individual PID. Always remember to act with caution, check the targets and use soft signals before resorting to brute force. With this knowledge, you will be better prepared to keep your Linux environment stable and responsive.


