2009-07-27 09:04:44

Kill shell session using pkill

Every once in a while, you need to include the ability for a shell script to commit seppuku, and to kill the shell that spawned it. This is sometimes needed if you're running a program which is known to hang the shell, for instance.

Another common usage, if you're a BOFH, is to replace a common executable file with a shell script that terminates the user's shell that executed the script. I'm making no judgments! :o)

/usr/bin/pkill -9 -s 0 -o

The command breaks down as:

  • pkill: base command
  • -9: kill signal for "terminate & exit immediately"
  • -s 0: session 0, which is pkill's own ID
  • -o: oldest process, which will be the shell

Tags:   linux     |    Perm Link:   Kill shell session using pkill



James Conner