So, I know you can pkill -U <uid>, but whenever I've used this, my entire system crashes. Further investigation shows it probably is because I'm not matching anything, so it matches everything? How can I effectively kill all processes running under a user?

  • When you crash the system, what UID are you trying to kill? If you try to kill everything run by root, well, you're going to be in for a bad time. . . – Eric Renouf May 17 '15 at 2:48
  • @EricRenouf No, It's a UID in the 6800s. I did this, though: killall -u ap_6857 -l -i, and got, HUP INT QUIT ILL TRAP ABRT IOT BUS FPE KILL USR1 SEGV USR2 PIPE ALRM TERM STKFLT CHLD CONT STOP TSTP TTIN TTOU URG XCPU XFSZ VTALRM PROF WINCH IO PWR SYS UNUSED – JavaProphet May 17 '15 at 2:52
  • I'm not quite sure what your command was showing. Did you do killall -u ap_6857 -l -i and see all the other things as output? If so, that's what the -l flag is for, to list the available signals to send? – Eric Renouf May 17 '15 at 2:55
  • 1
    pkill -U nonexistant-userid should kill nothing, not everything... Are you doing something like killing the userid you're logged in under? What does pgrep -U <uid> show? – derobert May 17 '15 at 3:03

you can use killall to kill, or send any other signal, to a bunch of processes at once. One of the "filtering" options is the owner:

 killall --user name1

I don't like killall (using it on solaris can cause disaster).

pkill is more portable

pkill -u username
  • I ended up settling on ps -u 6857 -o pid --no-headers and just kill <uid>, but this may work for others. – JavaProphet May 17 '15 at 3:02
  • May be it's respawn mode. – PersianGulf May 17 '15 at 3:22

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.