Skip to content

Instantly share code, notes, and snippets.

@thonixx

thonixx/kick.sh

Created Aug 25, 2013
Embed
What would you like to do?
kicks other users out of their sessions with a message would kick root which comes from a defined destination
# kick function
# kicks other users out of their sessions with a message
# would kick root which comes from a defined destination
function kick() {
if [ -z "$1" ]
then
echo "need user"
return
fi
tty=$(w | grep -i "$1" | head -n 1 | awk '{print $2}')
$(mesg y)
echo -n "
You were kicked out of your session.
Sorry :/
" | write root "$tty" 2> /dev/null
$(ps faux | grep -i "$tty" | grep -v "grep" | awk '{print $2}' | xargs -n1 kill -9)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.