View Full Version : [other] pkill or skill question

February 27th, 2009, 04:20 AM
So lets say I'm sshed into a remote linux machine and I see via "who" that there are 12 root sessions open. I want to kill them all but don't want to lose the ability to ssh back in. pkill -u root will kill sshd, right? skill doesn't seem to have an option for me either. Is there a different command or a way to exclude just a single process from the slaughter?


April 27th, 2009, 06:13 PM

April 27th, 2009, 07:49 PM
Since pkill can use regular expressions as the pattern, I think something like this would work:
pkill -u root [^sshd] I think that should kill all processes owned by root that don't have "sshd" in the name - although I haven't tried it myself, because to be honest, I can't imagine a situation where this would be desirable...

July 25th, 2012, 04:45 AM
> pkill -u root [^sshd]

A-ha-ha. This will kill allmost all processes whose name contain any non-s, non-h and non-d letter. I.e. amlost all processes.

July 25th, 2012, 05:17 AM
Thanks for sharing. Thread Closed.