Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

Apr 232010
 

How to avoid command being saved to shell history

Answer:

Firstly, you need to set the Bash shell environment variable to tell the shell to ignore the history if the command is starting with a particular character, e.g. a space in our case below.

# export HISTIGNORE="&:[ ]*"

Then, type the command start with a space

# who

And verify using the history command

# history

Apr 212010
 

Best way to kill all child processes forked by a given program

Answer:

Firstly, find the process group leader (i.e. master process that forked other processes) of the program, e.g. apache2

# sudo ps x -o  "%p %r %y %x %c " | grep apache2 

14787 14787 ?        00:00:00 apache2

To verify if it is the process leader.

# pgrep apache2 | sort -n | head -n1 
14787 

To issue kill to all the members in the process group

# kill -9 -14787