Force User Logout on Linux

There are two commands can be used: skill and pkill

  • Halt/Stop a user
    skill -STOP -u <username>
    

    or

    pkill -STOP -u <username>
    
  • Resume Halted User
    skill -CONT -u <username>
    

    or

    pkill -CONT -u <username>
    
  • Kill and Logout a User
    skill -KILL -u <username>
    

    or

    pkill -KILL -u <username>
    
  • Kill and Logout All Users
    skill -KILL -u /dev/pts/*
    
  • Kill all php-cgi process owned by a user
    pkill -KILL -u <username> php-cgi
    

Reference
https://www.cyberciti.biz/tips/howto-linux-kill-and-logout-users.html

Written on November 13, 2017