Process Termination Commands
Video Activity
Join over 3 million cybersecurity professionals advancing their career
Sign up with
Required fields are marked with an *
or
Already have an account? Sign In »

Course
Difficulty
Intermediate
Video Transcription
00:00
>> Hello Cybrarians and welcome back to
00:00
the Linux plus course here at Cybrary.
00:00
I'm your instructor, Rob Goelz.
00:00
In today's lesson, we're going to be
00:00
talking about process termination.
00:00
Upon completion of this lesson,
00:00
you're going to be able to understand why
00:00
processes might need to be terminated,
00:00
we're going to talk about the difference
00:00
between the different types of kill signals,
00:00
and then we'll see how the kill,
00:00
killall, and pkill commands are used.
00:00
Occasionally a process will get hung up,
00:00
sometimes the process resumes on its own
00:00
and then sometimes it needs a little bit of help.
00:00
Now, process termination is
00:00
required when a process is not only hung
00:00
up but now it's tying up
00:00
resources and causing problems
00:00
with all the other processes.
00:00
In all cases, a command is needed to control
00:00
the process and these are what are
00:00
known as inter-process communication,
00:00
and in Linux, signals are used
00:00
to perform inter-process communication.
00:00
A process signal is a predefined message and
00:00
most well-written applications can receive
00:00
these and act upon these process signals,
00:00
but that does largely dependent on
00:00
the developer and how well
00:00
they programmed their application.
00:00
There are 31 of these process signals in Linux,
00:00
but we don't need to know all of them.
00:00
Really, for the purposes of the exam,
00:00
we only need to know a few of these processes.
00:00
For example, SIGHUP,
00:00
which is this signal number one,
00:00
it hangs up, which means it just reloads
00:00
the process and reloads it with the same process ID.
00:00
We can do a SIGINT,
00:00
which is process ID or signal two,
00:00
and that is a signal interrupt.
00:00
This is what Control C actually does,
00:00
it interrupts the signal.
00:00
We can use SIGKILL,
00:00
which forcibly kills a process.
00:00
We can also do SIGTERM which terminates
00:00
a process gracefully, that's 15.
00:00
Now we could use SIGSTOP,
00:00
which is process ID or signal 20,
00:00
and that stops the terminal or pauses a process
00:00
and this is what we're actually doing when we
00:00
hit Control Z on the keyboard.
00:00
Now, the kill command is what we use
00:00
to terminate or signal a process,
00:00
so those command numbers that we used previously,
00:00
that's what we actually use with kill.
00:00
By default, kill takes a PID and terminates it
00:00
gracefully by using SIGTERM 15.
00:00
If you just do kill and then the process ID,
00:00
it's going to try and
00:00
>> terminate that process gracefully.
00:00
>> But kill has a lot of syntax options,
00:00
and these are all example options
00:00
that you can use to terminate gracefully.
00:00
We could do kill -15 PID,
00:00
we could do kill -TERM,
00:00
PID, we could do kill -s 15 PID,
00:00
and so on and so forth.
00:00
SIGTERM 15 is really
00:00
always the best option to start with.
00:00
You can use any of those syntax above to do that.
00:00
But if you can't get a process to terminate gracefully,
00:00
your SIGKILL is your last resort,
00:00
so you could use SIGKILL,
00:00
the process ID nine,
00:00
and the way that you do that with kill is by doing
00:00
kill -9 and then the process ID and
00:00
that will automatically and instantly
00:00
terminate that process in almost every case.
00:00
Now there are two other kill-related commands
00:00
you should know for the Linux plus exam,
00:00
and those are killall and pkill.
00:00
The killall command is used to kill all processes that
00:00
share a name or some other common characteristic.
00:00
For example, we could do killall httpd,
00:00
and that's going to kill all processes
00:00
that are named HTTPD.
00:00
These are going to be web
00:00
>> processes on a Red Hat server.
00:00
>> We can also do killall -u and then specify user,
00:00
and that will kill all processes that
00:00
are owned by that particular user.
00:00
However, we can also use pkill and
00:00
pkill is used to kill all processes that share a name.
00:00
For example, we could do pkill apache2 and that would
00:00
kill all Apache 2 web processes on
00:00
>> say, an Ubuntu system.
00:00
>> With that, we've reached the end of this lesson,
00:00
and in this lesson,
00:00
we covered why processes may need to be terminated,
00:00
we talked about the different types
00:00
of process or kill signals,
00:00
and then we saw how the kill,
00:00
killall, and pkill commands are used.
00:00
Thanks so much for being here and I look
00:00
forward to seeing you in the next lesson.
Up Next
Process Priority
Create, Monitor and Kill Processes
Virtual Lab
Module 23 Overview: Troubleshooting User Issues
Troubleshoot File and Directory Permissions
Manage File and Directory Permissions
Virtual Lab
Instructed By
Similar Content