How to prevent a process from executing in bash

bashkillterminaltty

The following command has been entered:

sleep 12h; nuke-russia

It was entered on one of the Debian's ttys. I would like to cancel the sleep without nuking anything. I don't want the nuke command to run for even for a single moment. I have the other five terminals available. What can I do?

Best Answer

In future, try using && instead of ;
sleep X && echo bla pressing ctrl + C will stop sleep and will not echo bla

If it's feasible, you could rename the responsible binary . That way bash will not be able to execute nuke-russia since it will not exist.

Other solution would be to kill the responsible shell

EDIT:
How to find PID of responsible shell (which should its parent)
If pid of sleep 12h is 1234
find responsible shell with ps -o ppid= 1234
Then kill it with kill -9

Related Question