In this video we'll talk about the way how you can manage processes with Kill.
So how does that work? Well, Kill is used to send signals to a process based on the pid.
Kill all is a convenient command line utility that can do the same, but it's based on process name.
You have already seen me using killall DD a couple of times.
Common signals are signal 15, which is sick term, and that instructs the process to stop.
This is a nice signal because the process will have time to finish its work.
Signal 9 is not so nice because that will force the process off and nothing will be stopped.
Other signals are specific to the commands that you are running. You won't run them very much. You know what
I want to do? I want to show you the difference between signal 9 and signal 15 from top.
So here I'm going to start top again and I'm pressing K. Now the process that I want to kill is process 7148. That is top itself.
And next it's asking for a signal. And the default signal that it wants to send is signal 15,
which is Sigterm. And sigterm is just fine with me. So I'm pressing enter and now it's gone.
Now what is the point that I want to make? Well, the point that I want to make
is that if we do it again, this time 7211, which is stop again and I'm going to
send it signal nine, then this is what is happening. You see what's happening? Nothing is cleaned.
Now this is a very clear demo that signal 9 doesn't allow the process to clean up anything at all.
The result is that if you use Signal 9 on important applications, you might cause some
damage here. So don't use signal 9, at least not before you have used signal 15.
If you do a signal 15, you wait a couple of minutes and the process is still there, then it might be okay to do a signal 9.
But normally you should try to avoid signal 9.
In case you wonder how can we clean up the screen. Well, just use clear. Clear is the magical command
that will always work and it will clear your screen. And as you can see, little bit stronger reset.
If the screen output is really a mess, then you use reset to regenerate new prompt.