Hey, folks, in this video, we are going to cover the Kill Command Kill Command is used a 10 minute
process.
It sends a signal which ultimately terminates or kills a particular process or group or process.
We use a system CTL command to stop a service.
And sometimes when we are trying to stop a service that has many processes associated with it, then
somehow it just wouldn't stop.
In that case, the kill command comes to your rescue.
You could use the kill with different options or signals to let the process know what to do.
The simple usage of a kill command is kill then option and the process IED.
Yes, you need a process ID to kill a process.
So the option in this case is the signal name or Signal ID, which is a telling or asking the process
what to do.
And the process ID, which we already covered, is actually the process I.D. of the process.
By the way, if you are thinking, where am I going to get the process ID, then of course you could
get the process ID either by running the command top or you could run the pass minus F command to get
the process ID and then you could use kill.
The option and the PID, you can actually skip the option and simply type, kill and process ID, which
is a default behavior, which is the signal name of SIG, a term which will kill the process.
All right.
So moving down kill minus ill is the command you need to get the list of all signal names or signal
numbers.
Yes, let's clear the screen.
And if you run kill minus L, you will see there are 64 signal names or signal and no numbers.
These signals once again are telling the process what to do, whether to restart, to stop or stop gracefully,
or to just stop forcefully.
There are the most commonly signals that are used by the system administrators are kill just by process.
It's not specifying any single name or single number, then kill minus ill, which will restart a process
kill minus two, which will interrupt from the keyboard.
It is just like as if you are typing controlled C to get your problem back killed minus nine.
And this is many times a use by system administrator, which is forcefully killing the process and then
killed minus 15, which is killing a process gracefully.
All right.
Before we go on to this other commands, let's try some of the commands that you learn.
So let's go back here and let's try a few of them one by one.
So let's say if you have a process that you want to kill so we we can check system CTL status firewall.
D or firewall dot service?
It is telling you that it is running and its process ID is 750.
Now you can stop this process or the service by doing systemctl Stop Firewall D.
But what if you trying it and it's just not listening to you, then what you could do is you could do
kill.
The prices ID 750.
OK, I'm getting the message saying operation not permitted.
Why?
Because I am.
Not rude.
Yes.
Let's become rude as humans and enter the password.
Clear the screen.
And now just simply to kill.
And what was the process, Heidi?
Seven five zero four five one, the hit enter.
It should be killed.
Now let's check the status again.
System CTL status.
Firewall.
And right here is telling you it's inactive and it is dead at sea.
You can stop it from here or you could stop it by using the kill command.
You can also do minus one or two restart that, so if I do kill, so I would need a process ID to restart,
of course.
So right now, if I wanted to do, let's say for firewalled, I can, because that process is already.
So let's start the process.
Start firewall, the.
OK, it has started.
Let's check the status to see what is the process ID?
Now it has given six to nine zero, let's clear the screen six to nine zero killed minus.
One six, two nine zero.
Let's check the status and right here it says it's running way because it's actually reloaded for you,
meaning restarted that service for you.
OK.
Killed minus nine, if you are trying, would just kill and process ID or kill minus two or something
like that or click kill minus 15.
And somehow that process is not dying.
Then you have to use kill minus nine forcefully.
This will forcefully kill the process regardless if it is waiting on any other process.
All right, so let's use that.
Let's say if I am running.
Let me open up another terminal in the other terminal, I'm going to run the command.
Sleep Command Sleep Command is just a command which will run based on the specified number of seconds.
So let's say if I want to run Sleep Command for 50 seconds, it is running.
Now let's check the process by running the command minus here and grep for sleep.
All right.
You could see I had that sleep 50 right here, and the process ID is 65 70, so I could do kill minus
a nine six five seven six six five seven six.
Yes.
Killed right away.
It says complete it.
And if you go back to the terminal behind it and you'll see you got your back and it's telling it it
is killed.
See how it works now.
Now this is the actual example that you could have.
Now you can also run the top command here, and you could see if any of your processes are running high
on CPU or memory, and you cannot actually find its parent process or the main service and name of that
process.
Then you could simply get its ID, come back to your terminal and simply type kill, followed by the
process.
All right.
In the next slide, I have other similar commands that can be used, for example, kill.
All this is going to kill all the product, a process, and it's all related or child processes.
Then the second one is the Pychyl.
Pychyl allows you to kill by the process name.
So let's say if you do not have a process IED, then you could actually simply use P Kill to kill a
process by its name.
Now, as a comparison to Windows Environment, if you go to task manager and right here you have process.
If you want to kill it, you could just simply right click and you just do end a task.
This will kill the process or application if you wanted to kill a specific process within that application.
You could do the same thing right click.
And you could do start or stop.
So right now, it is already stopped.
So let's see the one that is running right here.
This is one is running.
You could right click and stop.
So this is as if you are trying to use a command kill in windows environment.
I'll see you in the next lecture.