Simple BASH script to kick users from a Linux/Unix box.
The system manager can choose to kill all sessions from an user, or a specific session.
The script runs interactively and asks for confirmation before killing anything.
Requires root privileges to run.
Be advised that killing ssh sessions with programs open can have many adverse effects on your system!
You should know what you are doing and I take no responsibility for any damage caused by this script.
You should take full responsibility when kicking people on their faces, balls, or their open vi document.
From version 0.3.3 (or greater), kick.sh will show the user's process tree with pstree
before confirming the kick.
The script uses awk
, sort
, who
, killall
, pstree
and kill
, all of which are usually installed by default.
Uses who -u
to get the list of users and sessions.
Uses killall -u <username> -HUP
to kick a user.
Uses kill <PID>
to kill a specific session.
Uses pstree -npsu <username>
to show user's processes before kicking a user.
The script uses the environmental variable $LANG
to define its language.
If an unsupported language is detected, the script will run in English.
- en_US
- pt_BR
LANG="en_US.utf8" sudo ./kick.sh
LANG="pt_BR.iso88591" sudo ./kick.sh
Please note that even though the variable $LANG
requires the encoding,
kick.sh only uses the language part of the string to define the display language.
So if $LANG
is either "pt_BR.utf8"
or "pt_BR.iso88591"
would be the same for the display language.
The Makefile will install the script as kick
(without the .sh) to /usr/bin
.
Please change the makefile variables if you want to install it somewhere else or with another name.
sudo make install
sudo make uninstall
- Option to use
kill -9
in a session - Option to send message to the user that is going to be kicked, with sleep before killing
- Force language with cli parameter