Tuesday, June 15, 2010

How to Find the Process ID(PID) of Task and Killing the Task in Linux

open the terminal

switch to the root, by using following command
[subin@wipro-049cafd91 ~]$ su -
Password:
enter the root password and click on enter it will enter into the root
[root@wipro-049cafd91 subin]#

then enter the following command
[root@wipro-049cafd91 subin]# top

on clicking enter, it will show all the tasks which are currently in the host
by seeing the PID of the task, we can kill that particular task in the following way
before that you have to come out of the "top", for that press ctrl+c

now enter the following command
[root@wipro-049cafd91 subin]# kill 54789
on clicking enter this will kills the task in the host

Another way of finding the PID of task :
enter the following command in terminal
[root@wipro-049cafd91 subin]# ps aux | grep firefox

Note: here "firefox" is task name, it can be any task like netbeans, a folder, a file ........

by entering the above command it will gives the pid(process id) of the task

subin 27819 0.0 0.1 4436 1088 ? S 11:42 0:00 /bin/sh /usr/lib/firefox-1.5.0.9/firefox
subin 27842 0.0 0.1 4440 1096 ? S 11:42 0:00 /bin/sh /usr/lib/firefox-1.5.0.9/run-mozilla.sh /usr/lib/firefox-1.5.0.9/firefox-bin
subin 27847 7.7 2.6 94848 26840 ? Sl 11:42 0:00 /usr/lib/firefox-1.5.0.9/firefox-bin
root 27855 0.0 0.0 3884 692 pts/1 S+ 11:42 0:00 grep firefox

then enter the following command to kill the process

kill 27847

by this we can kill the firefox

1 comment: