This is an iEntry.com Website
Search iEntry News

Submit Your Site For Free!

Email Address:
* URL:
*
*Indicates Mandatory Field

Terms & Conditions

LinuxProNews
SecurityProNews
ITmanagement










Methods To Terminate A Process On Linux

By Praval Singh
Expert Author
Article Date: 2008-07-01

In our previous article - Sharpen your Linux vocabulary - we visualized few commonly used terms in context with the Linuxoperating system and its surroundings! I thank and appreciate the readers foradding on a few more words.

While I was figuring out a way to run Internet using a CDMA wireless modem onmy Linux machine, one of the applications refused to respond due to some rareerror. This very incident reminded me to come up with following article whichelaborates few methods to help you terminate a process or application running ona Linux distribution - something similar to 'end task' on a windows operatingsystem.

Remember, there is no Ctrl+Alt+Del key combination on Linux - by default!

Let us now see some of the interesting ways to kill those stuck and stubbornprocesses. A very mundane and primitive way is to use the command ps aux, look through the process list until you find the PID (process ID) you want and issue the kill command.

Alternatively, a better way is to use the 'killall' command which would automatically kill a program based on its name.

# killall mozilla-bin

There may be times when you shall only know a part of the name. In such ascenario, you can combine ps with grep, kill and awk to produce something like this.

# ps aux | grep mozilla | awk '{print $2}' | xargs kill

Now if that was tedious, there are still simpler ways. Enter pkill and theclosely related pgrep. All these commands are part of the sys-apps/procpspackage and are specifically designed to search for or kill running processes. The previous command could be replaced with the following:

# pkill mozilla

If you just need to list the PID's instead of killing them, you may just usepgrep.

Lastly, if you have a runaway process hogging /dev/dsp, or some other file orsocket, you can use fuser, which displays the PID's of process using a specified file or filesystem. You can give it the -k option and can easily kill those processes:

# fuser -k /dev/dsp

Now with the power of these commands, you shall never have the problem of 'killing' or stopping a process which you are unable to do otherwise.

Remember a fact that Linux has a lot of features which may not be evident bydefault or on the first look. But the depth it has considering the underlyingarchitecture and a strong command line integration is simply superb. I wouldadvise you to look out for a few HOW-TO's, hang around in the IRC's andparticipate in the discussions at various Linux forums - either as an audienceor a contributor.

More than an operating system Linux is a large community and strongrelationship between its members. A relationship of sharing knowledge andreusing it, unlike reinventing the wheel!

Comments

About the Author:
Praval Singh is a contributing writer for Brajeshwar.com.



Newsletter Archive | Article Archive | Submit Article | Advertising Information | About Us | Contact