FactorPad
Build a Better Process

Linux kill Command Summary with Examples

Linux kill allows you to send a signal to a process.
  1. Purpose - Learn what kill is for and how to find help.
  2. Options - Review a few common options and arguments.
  3. Examples - Walk through code examples with kill.
  4. A tip - Finish off with one more insight.
face pic by Paul Alan Davis, CFA
Updated: February 24, 2021
In this tutorial on Linux kill, 59 of 100, below find a 3-4 minute introductory video, a text-based tutorial and all of the code examples from the video.

Outline Back Tip Next

/ factorpad.com / tech / linux-essentials / kill-command.html


An ad-free and cookie-free website.


Examples of the Linux kill Command

Intermediate

Learn to stop processes gracefully at the Linux command line.

Video Tutorial

Videos can also be accessed from the Linux Essentials Playlist on YouTube.

Linux kill Command Summary with Examples (3:46)

Video Script

The Command and Why You Need It

Our fifty-ninth word, or command to memorize is kill from our category System.

kill allows you to send a signal to a process.

Common Linux kill Options
-options description
-l, -L List signal types by name or number
-s, --signal SIGNAL Send SIGNAL to the process

Recall from video 45, we used the ps command to view currently running processes. Here we'll learn how to use kill to, how do I say it, end a process.

Before we start, it helps to think of commands as mini programs and most follow this structure: command -option(s) argument(s).

The kill command has 5 options and the argument is the process id (PID).

Unlike most commands, help is not available with double-dash --help as kill is a shell built-in (builtin) on many Linux distributions. So instead try pointing to the program at /bin/kill with a --help or -h option.

The options are basically the type of signal to send. View signal types using -l for names, -L for number, and once you select the signal, use -s and the number or name.

So why is kill an important command? Well, for troubleshooting and general system sluggishness at times you have to intervene. And now you know how to do that.

Demonstration

Okay, the best way to embed this in your memory is by typing in your own terminal window.

Find this on your Mac using a program called Terminal. On Linux use Terminal or Konsole, and currently Microsoft is adding this functionality to Windows.

Here we go. Let's start by reviewing the different types of signals sent to processes, here with /bin/kill -L.

$ /bin/kill -L 1 HUP 2 INT 3 QUIT 4 ILL 5 TRAP 6 ABRT 7 BUS 8 FPE 9 KILL 10 USR1 11 SEGV 12 USR2 13 PIPE 14 ALRM 15 TERM 16 STKFLT 17 CHLD 18 CONT 19 STOP 20 TSTP 21 TTIN 22 TTOU 23 URG 24 XCPU 25 XFSZ 26 VTALRM 27 PROF 28 WINCH 29 POLL 30 PWR 31 SYS

The default is 15 TERM and for really misbehaving processes we have a number 9 KILL, and others to review later.

Next, use ps -a to see our processes.

$ ps -a PID TTY TIME CMD 215 pts/0 00:00:00 tmux 387 pts/1 00:00:00 sleep 444 pts/1 00:00:00 ps

Here's a sleep from video 43 and we don't need this any longer.

And last, at FactorPad, we don't condone killing anything, so instead we'll send a politely phrased command 15 TERM to the process id (PID) 387.

$ kill -s 15 387 [1]+ Terminated sleep 60m

And ps -a again to verify.

$ ps -a PID TTY TIME CMD 215 pts/0 00:00:00 tmux 444 pts/1 00:00:00 ps

Very good. (Oh, btw, we dressed our Terminal in black on the video for Halloween. Boo!)

A Final Tip

Okay now you know how to use kill. And you know the syntax for commands, options and arguments.

One last tip about the kill command. So please check out the man page for the command called signal for an overview on signals.

Okay, thanks for visiting today. I hope this was a helpful introduction to the kill command.


Learn More About The Series

For an overview of the 100 videos, the 8 quizzes, a cheat sheet, the categories and a Q&A section, visit:


What's Next?

For more dark humor, check out our YouTube Channel. Get reminders at @factorpad on Twitter or on our no-spam email list.

Outline Back Tip Next

/ factorpad.com / tech / linux-essentials / kill-command.html


linux kill command
linux kill
kill linux
linux stop process
stop process linux
killall linux
linux pkill
pkill linux
sighup linux
stop process linux
terminate process linux
linux ps command
process id
kill pid
term pid
linux process
process killer
task killer

A newly-updated free resource. Connect and refer a friend today.