Kill all processes for a given user

后端 未结 5 937
情深已故
情深已故 2020-12-12 12:52

Is there a reliable way to kill all the processes of a given user? kill(-1, SIGKILL) as that user will work, unless a rogue process of that user kills the killi

相关标签:
5条回答
  • 2020-12-12 13:20

    Just (temporarily) killed my Macbook with

    killall -u pu -m .
    

    where pu is my userid. Watch the dot at the end of the command.

    Also try

    pkill -u pu
    

    or

    ps -o pid -u pu | xargs kill -1
    
    0 讨论(0)
  • 2020-12-12 13:28

    Here is a one liner that does this, just replace username with the username you want to kill things for. Don't even think on putting root there!

    pkill -9 -u `id -u username`
    

    Note: if you want to be nice remove -9, but it will not kill all kinds of processes.

    0 讨论(0)
  • 2020-12-12 13:36

    What about iterating on the /proc virtual file system ? http://linux.die.net/man/5/proc ?

    0 讨论(0)
  • 2020-12-12 13:41

    The following kills all the processes created by this user:

    kill  -9  -1
    
    0 讨论(0)
  • 2020-12-12 13:44

    On Debian LINUX, I use: ps -o pid= -u username | xargs sudo kill -9.

    With -o pid= the ps header is supressed, and the output is only the pid list. As far as I know, Debian shell is POSIX compliant.

    0 讨论(0)
提交回复
热议问题