Kill User Session

Wednesday, September 24, 2014

how do I kill another Login User Session remotely - Linux, Centos

How do I kill all login users session in Linux  OS using command prompt ?

use "pkill" command which will look up or signal processes based on name. It can send the specified signal (such as KILL) to each process. following commands as root user:-

$ sudo pkill -9 -u username


OR
# pkill -9 -u username

To list all users pids, enter:
$ pgrep -u username

OR better try:
$ ps -fp $(pgrep -d, -u userNameHere)


Example: Kill Unix / Linux User Session :-

In this example, list all process owned by a user called lighttpd, enter:
# ps -fp $(pgrep -d, -u lighttpd)

Sample outputs:

UID        PID  PPID  C STIME TTY          TIME CMD
lighttpd   4703     1  0 04:20 ?        00:01:07 /usr/sbin/lighttpd -f /user/local/etc/.myconf/lighttpd/master.example.com.conf
lighttpd   4705  4703  0 04:20 ?        00:00:00 /usr/bin/php-cgi
lighttpd   4708  4703  0 04:20 ?        00:00:00 /usr/bin/php-cgi
lighttpd   4710  4703  0 04:20 ?        00:00:00 /usr/bin/php-cgi
lighttpd   4712  4703  0 04:20 ?        00:00:00 /usr/bin/php-cgi
lighttpd   4714  4703  0 04:20 ?        00:00:00 /usr/bin/php-cgi
lighttpd   4715  4703  0 04:20 ?        00:00:00 /usr/bin/php-cgi
lighttpd   4716  4710  0 04:20 ?        00:00:07 /usr/bin/php-cgi
lighttpd   4718  4705  0 04:20 ?        00:00:00 /usr/bin/php-cgi
lighttpd   4719  4708  0 04:20 ?        00:00:02 /usr/bin/php-cgi



To kill all process owned by lighttpd user, enter:
# pkill -9 -u lighttpd


Task: Kill and Logout All Users

The ultimate command to kill and logout all users is as follows:
# skill -KILL -v /dev/pts/*

0 comments:

About This Blog

Lorem Ipsum

  © Copyright 2009 Linux-HelpLine.Blogspot.com

Back to TOP