FactorPad
Faster Learning Tutorials

Linux kill command summary with examples

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.
Paul Alan Davis, CFA, October 31, 2016
Updated: August 4, 2018
In this tutorial, 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 Next

~/ home  / tech  / linux essentials  / kill command


The Linux kill command

Intermediate

Learn to stop processes gracefully at the Linux command line.

Video Tutorial

Linux kill command summary with examples (3:46)

Videos can also be accessed from the YouTube Playlist.

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.

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. Subscribe here.

  • For the Outline to all 100 tutorials, click Outline.
  • To go back to the history command, hit Back.
  • Learn another important system-related command called bg, click Next.

Outline Back Next

~/ home  / tech  / linux essentials  / kill command



 
 
Keywords:
linux kill command
linux stop process
kill linux
pkill linux
unix kill
process killer
terminate process linux
linux ps command
task killer
sighup linux
process id
stop process linux
linux kill examples
kill pid linux
term pid linux