How to remove/kill a process in Linux (kill)
In this article, we will see how to kill processes that are running on Linux and through the terminal of course, for when the need arises to stop something that is affecting our machine or we want to stop the process.
Finding processes on Linux
Well, first, before killing the process that is running on the machine, you need to know its name
So to find the process, we have several commands
The first one is the top, with this command we can see all processes in real-time on our machine
Also, lots of other information about it, see what happens when we type the top command in the terminal:
obs: to exit this view press ctrl + c
Another possible way to look for a process would be through the command ps aux with the help of grep to filter results.
This method is a search on the processes that are currently active on our Linux
Let’s, for example, search Sublime, a very famous text editor in the web field.
The command entered was:
ps aux | grep 'sublime'
The output is:
So see that we have three results, the first two are processes that are used to run the Sublime editor, and finally, we have the grep command itself that we use to find the process.
Well, at this point we already have two ways to find the process, we need to know now how to kill it.
How to kill the process on Linux
Now that we have important information like name and process ID.
We can choose two commands:
- kill: kill a process by ID;
- killall: kills a process by name;
If we type then:
We will kill the Sublime process, note that the ID may change according to how the process is created.
Probably on your machine, the process has another ID, I’m using the one that appeared when I typed ps aux.
And similarly, if we type this command:
We will be killing the Sublime process, and the editor closes
In this article were presented ways to kill processes that are running on Linux
We also saw how to check which processes are running, as we were able to check the names of which ones we have to eliminate
Making our task easier and also more accurate
And that’s it for today, until the next post!