Kick a user off your linux box

terminal-glossy.jpg

Lets say you run an ssh server allowing users to remotely login, but one may be troublesome, or you left an account logged in at another location by accident. You want to disconnect the user but don’t want to disconnect the machine or power the machine down. Well, you can boot them off and here’s how.

login to your server as root

type “w” (without quotes) to show who’s logged in to your server. See screenshot:

you can see what shell they are using in last column (“WHAT” column)

  • for example, if you want to force logout user “billyboy“, type “ps -u billybob“, this will show what applications that user “achmad” is run. See screenshot:

From the previous command (“w“) you know that user “billybob” is using “bash” as a shell. And from latest command (“ps -u billybob“) you know that “bash” that using by user “billybob” has PID , you’ll need to make a note of the PID for the bash process. To force logout a user, just type “kill -9 PID” (where PID is just put the PID you found for bash on that user. . And finally, user “billybob” is no longer on our system.

No Posts Found

One Comment

  1. oozie says:

    A Monthy-Python-scripted version of the above can be found here:
    http://blog.ooz.ie/2008/05/bash-kick-quick-way-to-get-rid-of.html