Linux - DistributionsThis forum is for Distribution specific questions.
Red Hat, Slackware, Debian, Novell, LFS, Mandriva, Ubuntu, Fedora - the list goes on and on...
Note: An (*) indicates there is no official participation from that distribution here at LQ.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Linux and all other UNIX like oses comes with kill command. The command kill sends the specified signal (such as kill process) to the specified process or process group. If no signal is specified, the TERM signal is sent.
Before I used to kill process in linux by finding the process Id.
For Ex: if i want to kill the process apache then i have to search the process first
(i.e) ps -ef|grep apache
Then i will display in the terminal like this
Then we have to use kill -9 pid every time.I thing its waste of time
For that better we can group all the PID and we can go for kill
So i have started using the command
ps -ef| awk /apache/'{print $2}'
Now it will group all the processID like this
7302
7303
7304
7306
7307
7308
7337
9314
Now we can use kill command finally by passing the output of the above command
kill -9 `ps -ef| awk /apache/'{print $2}'`
I will display in the terminal like this "bash: kill: (9382) - No such process"
(since command itself searching for apache so that PID only 9382 so its displaying no such process)
Alternative Way I
Another way to kill the process in a single shot is by using the command pidof
pidof command is usefull to find the process ID of a running program.
Now you want to kill apache then type
pidof apache
7302 7303 7304 7306 7307 7308 7337 9219
Now we can use kill -9 `pidof apache` to kill the process
Alternative Way II
killall -9 apache
Last edited by nthillaiarasu; 12-13-2007 at 04:52 AM.
That kills all 'apache' named processes. Handy sometimes. By the way, using switch -9 isn't needed all the time, and I consider it an ugly way to end a process
That kills all 'apache' named processes. Handy sometimes. By the way, using switch -9 isn't needed all the time, and I consider it an ugly way to end a process
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.