Do you sometimes feel annoyed due to the process getting hanged while working in the PC? Here’s the tutorial which will help you to know, how you can kill a process in Ubuntu. This is quite usual, for the processes getting slowed down due to the varied reasons, but however, this practice occurs rarely in the Linux environment such as Ubuntu, still there may be times when you may face this issue.
Now let me remind you what is a Process? A Process can be expressed as an object of a program that is being executed. Each process has its unique Process Identification Number i.e. PID. In Linux like operating system, the very first process which gets initialized is “init” process.
The process is responsible for the execution of a task. Sometimes the process becomes unresponsive and at that time you are required to stop or kill that process. In Ubuntu, you can opt for “GUI mode” or the “Terminal” to kill a process.
Steps to Kill a Process in Ubuntu
Method 1 of 1:
To kill a process through GUI Mode:
Step 1: Firstly, you must set a shortcut to kill a process through a Graphical User Interface (GUI).
At the top, you may see “settings” like symbol, click on it and then go to the “System Settings”.
Step 2: Then select the “Keyboard”.
Step 3: Here, you are required to click on the “Shortcuts” and then click on “add” button signified as “+” over here.
Step 4: Now you will be asked to name the Shortcut and in the Command section you have to write: “gnome-system-monitor” which is the actual command for the System Monitor.
System monitor is responsible for handling the processes in GUI mode. Click on “Apply” button.
Step 5: Shortcut is disabled for the time being, so click on the screen where “Disabled” is written.
Step 6: Once you place your cursor at “Disabled”, it will change to “New Accelerator” as displayed in the figure below. Then hold on the keys which you wish to set as for the System Monitor shortcut.
I have pressed Ctrl + Alt +Del which is similar to the default shortcut for the Task Manager in Windows, so that I could remember it.
Step 7: If this key is already assigned for some other task, then a dialog box will appear. Here, if you are sure what you are doing, then click on “Reassign”. Otherwise, choose cancel and set another combination of keys for the shortcut.
Step 8: The Shortcut is now created as shown in the figure below.
Step 9: You just need to press the keys simultaneously whichever assigned to open the “System Monitor”. The system monitor will open up in few seconds. You are free to kill any of the process.
I have chosen “gedit”, right clicked on it and then selected the “Kill Process” option.
Step 10: Warning window appears, if you are sure then press “Kill Process” button to kill that process.
Step 11: The process which I had selected to kill is no more available in the System Monitor, as you can see in the figure below.
Method 2 of 2:
To Kill a Process using Terminal:
Step 1: To use “kill” command you must know the process ID, for that use the command “pidof processname”.
For an example, I want to get the PID of Firefox, so I will type “pidof firefox” and press enter as shown in the figure below.
Step 2: As an output of aforementioned command, the PID will be displayed on your screen, which will be used further.
Step 3: Now, it’s time to use “kill” command. Type “kill -9 4548” where 4548 is the process ID and -9 is a signal to stop the process forcefully. You can use this command without “-9”. In the background, you can see the Firefox icon that means Firefox is still running.
Step 4: Once you press enter after writing kill command as discussed in the step 3, you will see that Firefox is stopped and you can see that, the process is no longer running.
Step 5: The other way to kill the process without using its PID and if you are not willing to write the full name of a process then you must go for “pkill” command. But before using it you should check for the processes having the keyword which you want to kill.
For an example: I am curious to delete the process having keyword “ged”. So, use “pgrep -l ged” that would return the list of processes corresponding to its PID having the characters “ged”.
It should be kept in mind that these keyword must be in between first 15 characters of the process.
Step 6: Here, you can see the process ID and its name, containing the keyword “ged”.
Step 7: You are now free to use “pkill” command. Lets talk about using it: type “pkill ged”, you can use the keyword suitable for the process, that you want to kill.
Step 8: Another command which you may use to kill the processes, is “xkill”.
The Xkill command pinches the X server to stop the clients running in your system.
Step 9: After using the Xkill command when you press enter, a message will appear as “Select the window whose client you wish to kill with button 1” and the cursor will turn into the cross sign. With the help of this you can close or kill the process which is running at the same time.
Step 10: Once you have completed the above mentioned operations, you may see a message on the terminal window as shown.
Step 11: Hey Guys, you can also use the “killall” command to kill the processes you wish. The major advantage of this command is that you can kill the processes simultaneously having different PID’s but with the same process name. “killkall” command terminates all the processes except the one which has generated the killall command. The killall comand can be used with various signals such as :
“killall -9 processname” : This command will kill all the process associated with the given process name. Here, you don’t have to enter the PID.
“killall -“ : This command will send the SIGTERM signal i.e. 15, that signifies to wait for 30 seconds and after that it will send signal 9 i.e. SIGKILL signal to kill the process.
Now I will show you to how to check the options which can be used with killall command. Just type “killall” on the terminal window.
Step 12: The Output corresponding to “kill” will display on your screen. Try the one you want.
That’s it guys, keep checking the website for new updates regarding HOW TO…
Leave a Reply