kill

>Usage

The command kill is used to send signals to processes, allowing for their termination or control. The kill command is essential for process management, particularly when a process is unresponsive or needs to be stopped.

>Synopsis

kill [OPTION] [PID] -[SIGNAL] [PID]

>Options

[PID]

Sends the default signal SIGTERM that terminates the specified process ([PID] stands for process ID). You can kill multiple processes simultaneously by providing all their PIDs. You can confirm that the process has terminated by running the command ps or jobs.

Example 1:

Dots

-zsh

> kill 12345


No output.

-l

Lists all available signal that can be sent to processes with their name and associated number.

Example 2:

Dots

-zsh

> kill -l


1) SIGHUP 2) SIGINT 3) SIGQUIT 4) SIGILL
5) SIGTRAP 6) SIGABRT 7) SIGEMT 8) SIGFPE
9) SIGKILL 10) SIGBUS 11) SIGSEGV 12) SIGSYS
...
15) SIGTERM

-9 [PID]

Sends the SIGKILL signal that forcefully kills the process. The SIGKILL signal cannot be caught, ignored, or blocked by the process, making kill -9 highly effective for ending unresponsive or "stuck" processes. You can confirm that the process has ended by running the command ps.

Example 3:

Dots

-zsh

> kill -9 12345


No output.

-15 [PID]

Explicitly sends the default signal to gracefully terminate the process by sending the SIGTERM signal, just like kill [PID]. You can confirm that the process has ended by running the command ps.

Example 4:

Dots

-zsh

> kill -15 12345


No output.

killall
[process_
name]

Sends the SIGTERM signal to all processes with the specified name. Be cautious when using killall, as it affects all processes with the specified name.

Example 5:

Dots

-zsh

> killall firefox


No output.

pkill [pattern]

Same function as killall but you get to specify a pattern to follow.

Example 6:

Dots

-zsh

> pkill -f my_script.sh


No output.

xkill

Forcefully terminates the application by clicking on its window. It is often used when a graphical application becomes unresponsive and cannot be closed through normal means, such as the window's close button.

Example 7:

Dots

-zsh

> xkill


The cursor will change to a cross or a skull icon, indicating that xkill is active and waiting for you to click on a window. Click on any window you want to close. The clicked window will immediately close without any prompt.

>Quiz

Progress: Question ? out of ?

Question Title

Page written by Sofia Mamone