Linux - How to force logout a user, Force logoff a user

How to force logout a user

How to force a user to logout from the server? To forcefully logout a user and make required changes on server, First find out how many sessions a user have login and also check wheter he is executing some important task, before force fully logout a user.

To find user who have login to server
 # who

 root     pts/0        2014-06-20 15:51 (xxx.xxx.xxx.xxx)
 bluff	  pts/2        2014-06-20 13:47 (xxx.xxx.xxx.xxx)
 bluff	  pts/3        2014-06-20 14:20 (xxx.xxx.xxx.xxx)
 guru     pts/4        2014-06-20 14:30 (xxx.xxx.xxx.xxx)

Find pid of session which has to be terminated
 # ps -ef | grep pts/2
 
 root      5490  4186  0 15:58 pts/0    00:00:00 grep pts/2
 bluff	  14995 14923  0 13:47 ?        00:00:00 sshd: bluff@pts/2
 bluff    14996 14995  0 13:47 pts/2    00:00:00 -bash

Kill process using processid
 # kill processid

 # kill -9 processid


 # skill -kill -u bluff

 # pkill -9 -u username

How To Halt/Stop a User
 # skill -STOP -u username

Resume Halted User
 # skill -CONT -u username

Kill and Logout a User
 # skill -KILL -u username

Kill and Logout All Users
 # skill -KILL -v /dev/pts/*

Terminate a session by killing its parent process, called the session leader
 # ps -dN | grep pts/2

 # kill -9 <processid>

The topic on Linux - How to force logout a user is posted by - Guru

Hope you have enjoyed, Linux - How to force logout a userThanks for your time

Tech Bluff