• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 801
  • Last Modified:

Terminating remote sessions

This is a simple question but I am new to linux :)

How can I terminate a remote ssh session to my debian box in the following example:

USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU  WHAT
ian      pts/0    00:11    1:26m  0.08s  0.05s  bash
ian      pts/1    01:55    0.00s  0.35s  0.02s  w

Any help will be much apreciated.
1 Solution
Errm, there's a column missing.  Each process listed should have a PID listed too.  If not, you might try fiddling with ps a bit (e.g. try "ps ux").  You might get a listing such as

 3001 ?        S      0:00 /usr/sbin/sshd
 3002 pts/1    S      0:00 -bash
 3159 pts/1    R      0:00 ps x

To terminate a process (that you own :), find that process' PID, and then execute the kill command on that.  For instance, if I wanted to kill bash above, I would execute the command:

kill 3002

After that, check to see that it's no longer running.  If your process is still running, you could try

kill -KILL 3002

Which, in all but the most extreme circumstances, will terminate the process.

I should note, for various reasons, you don't want to kill -KILL whenever you don't have to.  Try the first command first.
There is no pid information in the output from the command because it is the output from the 'w' command where you see who is logged into the system. in this listing you can see that ian is logged into pts/1 for example. Now you can use the command:

ps aux |grep pts/1

to list all processes on pts/1. Usually there is a process called -bash, and when you kill it you throw the user out. You may need to use the -KILL option ti kill (i think that is the same as -9 ). Be careful though if there are more than the -bash process running you may want to kill them first, or tell the user to finish them himself.

ijg0Author Commented:
Thanks Cygnus78. I did need to use the -KILL option as you said to terminate the session.  

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Tackle projects and never again get stuck behind a technical roadblock.
Join Now