Kill and Logout users in pts/* Linux

As a  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

Edit

There is some bug in recent Debian(7) and distros based on them like Ubuntu, which will make the command

skill -KILL -v pts/1

do nothing

What you can do in such case is to get the PID of the terminal you want to kill with

 skill -i -t pts/1

it will return something like

pts/1    root     27933 bash               ?

Just kill it –

kill 27933