ps ax | grep $1 | grep -v grep | while read f ; do pid=`echo "$f" | awk '{ print $1; }'` echo "# $f" echo "kill -9 $pid" done this script closes a process by substring and echo them on screen copy paste into a file named 'q' chmod +x ./q then q kdm will terminate all processes with substring 'kdm'