Linux Kill and Logout Users Command

S how do you kill a Linux user login session? Yet another newbie question that suggests sysadmin/people love to kill and show their power to the rest of the world. There is a package called procps. It includes various useful and nifty utilities. One of such utility is skill which is responsible to send a signal to users and process such as:

  • Halt user terminal
  • Kill user and logout

How To Linux Kill and Logout Users Commands

Linux Kill and Logout Users Command

The procps package contains utilities to browse the /proc/ filesystem, which is not a real file system but a way for the kernel to provide information about the status of entries in its process table. Procps includes the ps command, free command, skill command, pkill command, pgrep command, snice command, tload command, top command, uptime command, vmstat command, w command, watch command and pwdx command.

WARNING: Do not kill the process owned by the root user (UID 0) or PID 1. Keep in mind that killing necessary processes such as sshd or nfsd or httpd may result in the system downtown. Be careful with all commands. Think twice before entering any of the following commands.

How To Halt/Stop a User Called vivek on Linux

Open a command-line terminal (select Applications > Accessories > Terminal), and then type the following commands. First, switch to the root user by typing the su - and entering the root password, when prompted (you can also use the sudo command if configured on your machine). Type the skill command as follows:
# skill -STOP -u vivek
The skill command sends a terminate command (or another specified signal) to a specified set of processes.

Resume Halted User Called vivek in Liuux

Send CONT single to user vivek, type the following command:
# skill -CONT -u vivek

Kill and Logout a User Called vivek under Linux

You can send KILL single, type the following command:
# skill -KILL -u vivek

Kill and Logout All Users

The ultimate command to kill and logout all users is as follows:
# skill -KILL -v /dev/pts/*

WARNING! These tools are obsolete, unportable and it is here due to historical reasons. Consider using the killall, pkill, and pgrep commands instead as follows.

The pkill command

To halt or stop a user called vivek, enter:
# pkill -STOP -u vivek
Say you want to resume a user called vivek who was halted previously by the pkill command, enter:
# pkill -CONT -u vivek
Finally kill all php-cgi process owned by vivek user, enter:
# pkill -KILL -u vivek php-cgi

How to kill a Linux login session remotely

We can kill a Linux login session remotely by sending a hangup signal (SIGHUP) to the process running the login session. Typically BASH or KSH shell runs the login session. First, find out your current tty as we need to avoid killing ourselves. Type the tty command and press the [Enter] key:
# tty
Say you want to see all of the running processes of a user named wendy, enter:
# ps -fu {userNameHere}
# ps -fu wendy

Look for the PID (process ID) in the second column. The sixth column shows the TTY to which your processes are connected. The last column gives a process name, which is a login shell. Finally, we are going to remove the remote shell. You must look for the shell PID and choose the PID that is not for your current tty and type:
# kill -HUP {PID}
# kill -HUP 25250

Other useful nifty utilities provided by procps package

  • w command : Show who is logged on and what they are doing.
  • kill command : Send signal to a process (explains how to kill process under Linux)
  • top command : Display Linux tasks and other important stuff
  • vmstat command : Display virtual memory statistics.
  • free command : Display free and used memory (RAM) statistics.
  • slabtop command : Display kernel slab cache information in real time.


We cannot kill processes that are running on a Linux server other than the one you are logged into right now. For other remote Linux servers first, ssh into that box and run the above commands to kill users and log out of the systems. Set TMOUT to automatically log users out after a period of inactivity. See how to automatically logout BASH / TCSH / SSH users after a period of inactivity for more info.

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 40 comments so far... add one
CategoryList of Unix and Linux commands
Disk space analyzersncdu pydf
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
40 comments… add one
  • max Aug 15, 2006 @ 8:48

    This stuff is very cool!
    I manage an iternet cafe linux-based and to log-out users remotely since now I first logged in the client machine via ssh and then export DISPLAY=:0 and kdeinit_shutdown.But doing that I was lucky with kde as default wm, while ‘skill -KILL -u user’ is a better one_line command solution and for (I guess) all windows managers.
    What I’m still wondering is: how to login remotely a user assuming that the default login manager is kdm?
    Thanks in advance for any hint.

  • 🐧 nixCraft Aug 15, 2006 @ 9:39

    Hey max,

    Great to know you are using Linux for your internet cafe.

    skill should works with an wm or shell as it directly sends a signal to user.

    >What I’m still wondering is: how to login remotely a user assuming that the default login manager is kdm?

    Sorry but I am not getting your question. Can you explain it little more?

    • Ammar Shaikh Jan 11, 2012 @ 7:56


      I m also not getting your question so please explain it briefly or understandable that is very helpful to you and all also…

  • max Aug 15, 2006 @ 12:01

    >Sorry but I am not getting your question. Can you explain it little more?
    Well, when a customer finish his session is comfortable for me remotely close the session, but when I need to start a new one I need to sit-up from my chair and then go to the client and put the passwd (the user account is setted as default in kdm config) manually in the kdm welcome_login_window.
    Now I’m just wondering how to put remotely the passwd in kdm to open the session again without (being lazy :-]) uprise from my chair?
    I hope this wouldn’t be a too much tricky question an sorry about my english that isn’t my first language @^_^@

  • 🐧 nixCraft Aug 15, 2006 @ 19:03

    Now, I understand your problem, you do not want go to each PC everytime new customer arrives. You can kill your customers session with skill but now you want to do auto login right from your own admin PC

    Well I do not have exact solution but you can use KDE auto login facility to login the user automatically…

    On the other hand, you may be writing some script, which will log them automatically

    Another solution is kill user using skill
    When new person comes for browsing just tell him to seat in front of computer
    You login from your own admin pc to remote linux desktop system over ssh
    And you type the command startx&
    It will start the session on remove computer
    In order to work this all system must boot to text mode
    SSH should be running on all system
    And autologin must be turned on for all linux system

    Hope this helps

  • deivs Jan 22, 2007 @ 10:30

    how to logout specified user after one hour automatically,how to do ?

  • 🐧 nixCraft Jan 22, 2007 @ 15:11


    You need to write a script. There is no inbuilt facility available, AFAK

  • Paul May 15, 2007 @ 19:54


    I was pleased to see the skill inf have ld sessins n an LTSP server. I have since set a timeout uing TMOUT=7200 in /etc/profile.
    Iuse skill -KILL -u paul to try and remove the old sessions. It succesfully removed one but doesn’t seem to remove the other 2 that are reported by ‘who’. Is it possible that ‘who’ is reprting stale/non-existant sessions?

  • 🐧 nixCraft May 16, 2007 @ 9:46

    Try to use pkill command
    pkill -KILL -u username

  • Masood Yarmohammadi May 27, 2007 @ 15:39

    i use
    skill -KILL -u didi root

    Now, i can’t login to ssh!

    • Waqar Jun 13, 2011 @ 6:52

      That’s Because u also killed “SSH”, u need to login via console and restart SSH Services.

    • Jouni "rautamiekka" Järvinen Dec 5, 2016 @ 20:47

      -Never- run the command targeting §root§, you’ll regret it !

  • Hong@macau Jul 18, 2007 @ 9:34

    i think when i enter this command
    skill -KILL -u root

    this will be kill all the process that create by root. such as ssh telnet process.

    • Jouni "rautamiekka" Järvinen Dec 5, 2016 @ 20:45

      There should -never- be need to run these commands on §root§ itself ! You essentially fuck your system up, which means you need to force reboot through a switch.

  • deivs Sep 16, 2007 @ 9:38

    script to logout the users in the specific time

  • De.. Dec 7, 2007 @ 21:09

    i want to delete the process because my systems average load is too high 150.0 and more some time
    and when i delete them ..they goes to and start increasing the load continously..
    the process are perl scripts..
    please help urgent

  • De.. Dec 7, 2007 @ 21:11

    the process hang up and when i shen them it shows like “defunction”

  • Terry Jan 8, 2008 @ 21:05

    Oops didn’t read through all the threads. I had a user who was logged on remotely as root but when I ran the command we were kicked out of our SSH sessions
    Is there any way to recover SSH functionality short of rebooting

  • Anonymous Sep 5, 2008 @ 4:00

    Only if you have another way of logging in (e.g. telnet, vnc, etc)

  • Afrizal Oct 11, 2008 @ 16:16

    Thank you for your shared knowledge.

    Great info.



  • lee o Nov 9, 2008 @ 18:01

    Something for Linux Monty Python fans – one of you show a more funny way of kicking users off a linux box than THIS ONE HERE.. Very entertaining!

  • viper Dec 6, 2008 @ 7:46

    how about to remove halt application..
    at the bios I can’t find to solve that..

  • kaminisuresh Feb 26, 2010 @ 11:05

    this is suresh i want which pc is having some server,how to identify which is having server

  • bishnoink Sep 15, 2010 @ 5:01

    I have tried “skill -KILL /dev/pts/*” its not working on rhel5.

    alternative to kill all users sessions except “root” is:

    who -w|awk ‘{print $1}’|grep -v root|xargs skill -KILL -u
    *don’t forget to use “grep -v root” otherwise this will kill all the processes.


  • Bilal Bhat Nov 28, 2010 @ 7:27

    Brilliant bishnoink, you made my life easy… Thanks for sharing the command…

  • Mish Mar 9, 2011 @ 13:12

    I wanna know, how to block the users being ruining programs in bios level.
    this is like blocking websites for various users in bios level.

    ex; user “A” logging and browse internet (
    after user “B” logging and browse the internet BUT HE CANT GO TO “” from any browser.

    If you all have a suggestions how to block this kind of a session, I would be much appreciated.


    • Jouni "rautamiekka" Järvinen Dec 5, 2016 @ 20:52

      For the future: you seem to have a misunderstanding. BIOS is used to boot your computer to the point of capable executing the operating system, therefore saying you wanna use BIOS for that is completely wrong, it’s not possible. There are various ways to do what you want (or at least try to), but what it involves depends on the method.

  • Vishnu Ram May 26, 2011 @ 9:04


    I need to kill an user session which is not being used by that particular user for last 10 days. Please help me to get a script for that.

  • Naresh Kumar May 26, 2011 @ 12:19

    @ Vishnu,

    You can use following command.
    who -w|awk ‘{print $1}’|grep username|xargs skill -KILL -u

  • Mehdi Sep 8, 2011 @ 14:22


    If all the sessions have been made by a user, i.e. vivek, is it possible to kill a session based on TTY?

  • Daniel Vieceli Mar 13, 2012 @ 2:06

    Thanks, very good.

  • PVIBES Mar 7, 2013 @ 20:37

    I found this guys.
    Just replace USERNAME with the desired user session to be killed.

    kill -1 `ps ax | grep -i USERNAME | grep -i priv | cut -d ” ” -f 1`

    • Jouni "rautamiekka" Järvinen Dec 5, 2016 @ 20:56

      Whatever you do, -don’t- run that command with §root§ as the username !

  • cilgin_dj_hore Apr 28, 2014 @ 16:01

    aq ibneleri hey dude this fucking code skill -STOP -u root fucked my machine . i di o T

  • chika Aug 29, 2014 @ 7:34

    pkill -9 -u ardi

  • Anon May 4, 2016 @ 17:46

    cilgin_dj_hore Dude, if you have no CLUE what your doing stick WITH WINDOWS

  • Anon May 4, 2016 @ 17:47

    Root is the top level of the administrative hierarchy, you cannot skill / pkill root unless you are root then your killing yourself – DUMMY

  • Gustavo Arnosti Neves Sep 30, 2016 @ 10:31

    Based on some examples here and around I ended up cooking this interactive script to manage ssh sessions.

    It is called

    Could still use some additions, but works fine for me.
    Hope it is useful for others too.
    But be careful when kicking people around. 🙂

  • lol Feb 7, 2017 @ 16:04

    Fucking idiot. I should’ve read the comments. But honestly you need to specify shit like this. I ran the said command to kill a user with uid0 and gid0 that was a different username (not root) and now my box has no ssh. Fuck off. I hope nobody tries to do what I did.

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum