linux强制注销其他在线用户,在Linux下强制注销其他用户

[bash]#!/bin/bash

#=============================================#

# To force logout sb Modify by ihipop #

# ~~~~~~~~~~~~~~ #

# ihipop.info 19:42 2010-8-20 #

#---------------------------------------------#

function userpids(){

if [ $# == 1 ]; then

ps -o pid= -u $1

else

echo "Usage: userpids "

fi

}

function ttypids(){

if [ $# == 1 ]; then

ps -o pid= -t $1

else

echo "Usage: ttypids "

fi

}

MESSAGE="$HOME/.kick/message"

case $# in

# if only one argument is specified, kick out the user

1)

# check if the user is in the system

if [ "$1" == "root" ]; then

echo "Suicide is not allowed for root user!"

exit

fi

i=whoami

if [ "$1" == "i" ]; then

echo "Suicide is not allowed!"

exit

elif [ "$i" != "root" ]; then

echo "Acces Denied~!"

exit

fi

getent passwd $1 >/dev/null

if [ "$?" == "0" ]; then

# if exists...

TTYS=$(ps -o tty= -u $1|grep -v '?')

for TTY in $TTYS; do

cat $MESSAGE > /dev/$TTY

done

i=userpids $1

if [ "$i" != "" ]; then

kill -9 $(userpids $1)

else

echo "User didn't logged in!"

fi

else

# otherwise...

echo "$1: No such user"

fi

;;

# if two, then kill processes on the tty=$2

2)

TTY=$2

# check if tty exists

if [ -e /dev/$TTY ]; then

# show the message first

cat $MESSAGE > /dev/$TTY

kill -9 $(ttypids $TTY)

else

echo "$TTY: No such tty"

fi

;;

# if no, then show usage

*)

echo "Usage: kick "

echo " kick tty "

;;

esac

[/bash]

[text]

: :

: :

: :

: :

: :

.' :

_.-" :

_.-" '.

..__...____...-" :

: \_\ :

: .--" :

.__/ .-" _ :

/ / ," ,- .'

(_)(,(_,'L_,_____ ____....__ _.'

"' " """"""" """ hei,FUCK you!

[/text]

skill -KILL -u username

pkill -kill -t tty

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值