1

There are a lot of bash processes running on my Ubuntu Linux (12.04). Even when I close the terminal they are still shown in the System Monitor.

I tried killing them as below, but they remain as it is. How to diagnose the issue, why can't they be terminated?

user$ ps aux | grep bash
user    2807  0.0  0.0   9484    56 pts/20   Ss+  Mar18   0:00 /bin/bash
user    4431  0.0  0.1   9228  5616 pts/7    Ss   10:39   0:00 bash
user    4655  0.0  0.0   4372   844 pts/7    R+   10:45   0:00 grep --color=auto --exclude-dir=.svn bash
user    5664  0.0  0.0  12764    12 pts/6    Ss   Feb05   0:01 /bin/bash
user    5812 99.6  0.1  11276  7088 ?        Rs   Sep22 3923:00 bash
user    6174  0.0  0.0  13016    28 pts/19   Ss+  Feb13   0:04 /bin/bash
p        10964  0.0  0.0  11700    28 pts/2    Ss+  Feb11   0:01 bash 
p        11126  0.0  0.0   7952   560 pts/3    Ss+  Feb11   0:00 bash 
user   18195  0.0  0.0  17320   344 pts/9    Ss+  Apr22   0:29 /bin/bash
user   21721  0.0  0.0  15924     4 pts/10   Ss+  Feb01   0:10 /bin/bash
user   22915  4.7  0.3  19400 13056 pts/22   Rs+  Jul29 3950:07 /bin/bash
user   24030  0.0  0.0  13740     4 pts/23   Ss+  Mar24   0:15 /bin/bash
user   29787  0.0  0.1   9220  5572 pts/11   Ss+  Sep23   0:00 /bin/bash
user$ 
user$ pkill -f bash
pkill: 10964 - Operation not permitted
pkill: 11126 - Operation not permitted
user$ sudo pkill -f bash
user$ 
user$ ps aux | grep bash
user    2807  0.0  0.0   9484    56 pts/20   Ss+  Mar18   0:00 /bin/bash
user    4431  0.0  0.1   9228  5616 pts/7    Ss   10:39   0:00 bash
user    4660  0.0  0.0   4372   844 pts/7    R+   10:45   0:00 grep --color=auto --exclude-dir=.svn bash
user    5664  0.0  0.0  12764    12 pts/6    Ss   Feb05   0:01 /bin/bash
user    5812 99.6  0.1  11276  7088 ?        Rs   Sep22 3923:21 bash
user    6174  0.0  0.0  13016    28 pts/19   Ss+  Feb13   0:04 /bin/bash
p        10964  0.0  0.0  11700    28 pts/2    Ss+  Feb11   0:01 bash 
p        11126  0.0  0.0   7952   560 pts/3    Ss+  Feb11   0:00 bash 
user   18195  0.0  0.0  17320   344 pts/9    Ss+  Apr22   0:29 /bin/bash
user   21721  0.0  0.0  15924     4 pts/10   Ss+  Feb01   0:10 /bin/bash
user   22915  4.7  0.3  19400 13056 pts/22   Rs+  Jul29 3950:29 /bin/bash
user   24030  0.0  0.0  13740     4 pts/23   Ss+  Mar24   0:15 /bin/bash
user   29787  0.0  0.1   9220  5572 pts/11   Ss+  Sep23   0:00 /bin/bash
  • What does kill 29787 do? What about kill -9 29787? – mdd Sep 25 '15 at 2:59
  • @MatthiasDiener sorry, didn't see the comment earlier. I rebooted PC and now the problem is gone. I had tried killing by PID but it didn't work (i think it gave no output on terminal) – user13107 Sep 25 '15 at 3:57
  • First you need to stop those bash processes then kill it. Also make sure you should either be the owner of the process or a privileged user to kill a process. – Anwar Sep 25 '15 at 4:08
  • @user13107, No output in the terminal means that it worked. Even when pkill does not work, kill -9 should most definitely work when running as root. – Peschke Sep 25 '15 at 5:49
  • @peschke be careful. No output means it did not result in an error. Whether or not it worked is an entirely different matter. – Philip Couling Apr 9 at 23:09
0

Do not you think that you can not kill bash in your system? You run an application/program in bash and you can kill a program that runs in bash. Now you find all processes ID programs that run in bash. as you showed on your terminal:

> user    4660  0.0  0.0   4372   844 pts/7    R+   10:45   0:00 grep
> --color=auto --exclude-dir=.svn bash

Try to kill that process:

sudo kill 4660

or

sudo kill  -9 4660

let me know what happeens

0

Note that the "unkillable" bash processes are running as user p:

user    6174  0.0  0.0  13016    28 pts/19   Ss+  Feb13   0:04 /bin/bash
p        10964  0.0  0.0  11700    28 pts/2    Ss+  Feb11   0:01 bash 
p        11126  0.0  0.0   7952   560 pts/3    Ss+  Feb11   0:00 bash 
user   18195  0.0  0.0  17320   344 pts/9    Ss+  Apr22   0:29 /bin/bash

You're running as user user so you cannot just kill any processes of user p.

If you have sudo access, you could issue the kill commands either as root or as the p user. For things that might be old user sessions, using kill -HUP would be better than just kill, as it allows things like editors to save a backup of any unsaved work before exiting. Also, interactive shell processes (i.e. old sessions) can be immune to a regular kill, but kill -HUP works just fine for them.

To issue the kill command as user p:

user$ sudo -u p kill -HUP 10964 11126

or by using root power:

user$ sudo kill -HUP 10964 11126

For processes running as user p, a kill command issued as user p will be just as strong as a kill command issued by root: even regular users have complete power over the life and death of any process they own themselves.

  • I'm noticing that there is a bash process using 99.6% of a CPU in the output of ps in the question. This may be the one that they want to actually terminate. It doesn't terminate though (and no other bash process seems to die either). I've voted to close the Q as unreproducible/problem went away. – Kusalananda Mar 7 at 8:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.