Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 08-03-2010, 01:23 AM   #1
Registered: Sep 2009
Posts: 684
Blog Entries: 2

Rep: Reputation: 37
How to kill all processes except shell window?

Hi i was referring to an article given in following website.
I was surprise to know that i can kill all running processes by using kill 0.
However when i tried running the command nothing happened.

How would i establish this task?
my machine details:
# lsb_release -a
LSB Version:    :core-3.1-ia32:core-3.1-noarch:graphics-3.1-ia32:graphics-3.1-noarch
Distributor ID: EnterpriseEnterpriseServer
Description:    Enterprise Linux Enterprise Linux Server release 5.2 (Carthage)
Release:        5.2
Codename:       Carthage

Last edited by pinga123; 06-21-2011 at 06:06 AM. Reason: kill o is modified to kill 0
Old 08-03-2010, 01:34 AM   #2
LQ Guru
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Hi -

Yes, that a commonly cited "fact" on sites like And it's utter nonsense.

Here's the truth about "kill -0" (note: "dash zero", not "little oh"):

If you have a process ID but aren't sure whether it's valid, you can use the most unlikely of candidates to test it: the kill command. If you don't see any reference to this on the kill(1) man page, check the info pages. The man/info page states that signal 0 is special and that the exit code from kill tells whether a signal could be sent to the specified process (or processes).

So kill -0 will not terminate the process, and the return status can be used to determine whether a process is running
Now THAT's an answer that might impress an interviewer
Old 08-03-2010, 01:39 AM   #3
Registered: Sep 2009
Posts: 684

Original Poster
Blog Entries: 2

Rep: Reputation: 37
Originally Posted by paulsm4 View Post
Hi -

Yes, that a commonly cited "fact" on sites like And it's utter nonsense.

Here's the truth about "kill -0" (note: "dash zero", not "little oh"):

Now THAT's an answer that might impress an interviewer
So it is used to check if the process is running or not.
and there is no such command to kill all processes except shell window .
Correct me if i m wrong.
# kill -0 5071
[root@TomcatServer ~]# echo $?
[root@TomcatServer ~]# kill -0 5169
-bash: kill: (5169) - No such process
[root@TomcatServer ~]# echo $?

Last edited by pinga123; 08-03-2010 at 01:43 AM.
Old 08-03-2010, 03:04 AM   #4
Gentoo support team
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,079

Rep: Reputation: 401Reputation: 401Reputation: 401Reputation: 401Reputation: 401
I don't know what do you mean when you say "except shell window".

First, the shell is one thing and the "window" (whatever window it is) is a completely different thing/process. Even more, if you have such a thing as a window then you are definitely not running just a couple of processes, because that means you are in X, which is probably run via a wrapper (xinit or whatever else) which also runs a window manager (or more likely, a desktop) which probably launches a couple dozen processes in the background. In any case, you definitely need init (the parent of all the processes) and also a given amount of daemons that are launched by init while booting your system.

At most, you could use "init 1" to go to runlevel 1, which will in turn kill *most* processes. That's the less you will get from a Linux OS while retaining some functionality unless you are ready to write a kernel module that can be used as a shell.

Last edited by i92guboj; 08-03-2010 at 03:06 AM.
Old 08-03-2010, 03:35 AM   #5
LQ Newbie
Registered: Jul 2010
Posts: 5

Rep: Reputation: 0
yup, taht's true


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to kill shell window Paris Heng Linux - Software 3 06-11-2009 12:27 PM
Use only one "kill" to kill father and child processes Xosen Programming 7 08-28-2008 04:33 AM
shell script to kill processes running on port number varunbihani Linux - Newbie 13 12-06-2005 09:46 AM
how to use kill to kill a batch of processes with same name? dr_zayus69 Linux - Software 2 09-03-2005 07:35 PM
shell script to kill all processes on specified port varunbihani Linux - General 1 04-19-2005 06:39 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:23 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration