Kill and Logout users in pts/* Linux

As a junior linux administrator you may need to force logout and kill a specific user, or an active user in pts/0 pts/1 pts/3 etc. Also this tutorial will work in most linux distros.
First of all display the out put of  "w" command.

[root@server ~#]w
18:08:30 up  3:54,  3 users,  load average: 0.05, 0.02, 0.00
USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT
root     pts/0    192.168.10.100     14:15    0.00s  0.05s  0.01s w
james    pts/1    192.168.10.100     18:07   50.00s  0.02s  0.02s -bash
james    pts/2    10.10.20.23     18:07   39.00s  0.02s  0.02s -bash

Here the user "james"  is logged in from two different machines. And you need to force logout and kill the user "james" logged in from ip: 192.168.10.100 (pts/1)

use the below command
[root@server ~#]skill -KILL -v pts/1
This command will force logout and kill the user in pts/1. and the same user logged in pts/2 will not be logged out.

If need to kill a users all the connected sessions at once
[root@server ~#]skill -KILL -u james          (this will kill both pts/1 and pts/2 cessions)

To STOP/PAUSE a user's activities
[root@server ~#]skill -STOP -u james 

To RESUME a stopped user
[root@server ~#]skill -CONT -u james

Click here for complete Guide on User/Groups management in Linux

Was this helpfull ?

1 comments:

fietronic said...

I couldn't get skill to work right.

I figured out, on my system:
skill -9 -v -tpts/2

No -v for verbose -t for "the following is a tty" but with no space after the -t. -9 is the same as -KILL... or SIGTERM.. one of those.

Related Posts Plugin for WordPress, Blogger...

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Bluehost Coupons