Monday, December 24, 2012

Kill User Session on Linux/Unix

You need to have admin access to kill an user session. First : Get the process id of the user session using the who command. Second:Kill the process using the kill command with option- 9.

For example: Lets say, we want to kill the guest user session having pid 7317 as below

~$ who -u
deepak   tty7         2012-12-25 07:16  old         2531 (:0)
deepak   pts/1        2012-12-25 07:53   .          4481 (:0)
guest-qIU5kr tty8         2012-12-25 15:11  old         7317 (:1)

~$ kill -9 7317
bash: kill: (7317) - Operation not permitted
~$ sudo kill -9 7317
[sudo] password for deepak:

~$ who -u
deepak   tty7         2012-12-25 07:16  old         2531 (:0)
deepak   pts/1        2012-12-25 07:53   .          4481 (:0)

~$

No comments: