How on Linux to learn the process PID and terminate it

On Linux operating systems, each process has its own identifier (PID).

We list all the processes and look at their PID:

ps axu

Filter by process name, for example apache2:

ps axu | grep apache2

You can also see the PID of the process by running the command:

pidof apache2

List of signals and their numbers that can be sent to the process:

kill -l

We kill the process (where PID is the process number, the SIGTERM signal is sent to the process as standard):

kill PID

We kill the process with the signal (for example 9):

kill -9 PID

An example of terminating processes by name:

killall apache2
killall -s 9 apache2

Help for commands:

man ps
man grep
man pidof
man kill
man killall

Root rights may be required to kill some processes, then sudo must be added before the commands.

Leave a comment

Leave a Reply