LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 01-04-2006, 03:59 PM   #1
wwnexc
Member
 
Registered: Sep 2005
Location: California
Distribution: Slackware & Debian
Posts: 264

Rep: Reputation: 30
Terminate Session Remotely


I was wondering how i can see all the users logged in to a computer (via ssh) and terminate their session, if needed.

So basically what i am asking is:
-how do i see all logged in users (via ssh)
-how do i terminate somebody else's session remotely (over ssh, as root)

Thanks!
 
Old 01-04-2006, 04:02 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,393

Rep: Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963
1) w

2) kill <pid>
 
Old 01-04-2006, 05:19 PM   #3
generic_genus
Member
 
Registered: Oct 2005
Distribution: Gentoo Unstable
Posts: 51

Rep: Reputation: 15
I'd use

killall -u <user>
 
Old 01-04-2006, 05:44 PM   #4
wwnexc
Member
 
Registered: Sep 2005
Location: California
Distribution: Slackware & Debian
Posts: 264

Original Poster
Rep: Reputation: 30
I haven't had a chance to "kick" anybody yet, but wouldn't kill or killall just terminate the user's processes, not log them out?
 
Old 01-04-2006, 05:47 PM   #5
generic_genus
Member
 
Registered: Oct 2005
Distribution: Gentoo Unstable
Posts: 51

Rep: Reputation: 15
killall definitely does the trick, just su to a user (su <user>, hopefully not patronising you there) then open a root shell and try killall, and voila

Last edited by generic_genus; 01-04-2006 at 05:48 PM.
 
Old 01-04-2006, 08:36 PM   #6
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,977
Blog Entries: 11

Rep: Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879
Quote:
Originally Posted by wwnexc
I haven't had a chance to "kick" anybody yet, but wouldn't kill or killall just terminate the user's processes, not log them out?
How do you think does the user stay "logged in" if you
rip the shell he's using away from under his bottom? :}


Cheers,
Tink
 
Old 01-04-2006, 08:40 PM   #7
wwnexc
Member
 
Registered: Sep 2005
Location: California
Distribution: Slackware & Debian
Posts: 264

Original Poster
Rep: Reputation: 30
Great way of putting it, Tinkster. Now i get it: no shell, no "being logged in". To get back the shell, the user has to enter his password again. Problem solved!!

I never knew that there was a command "W". Thanks for the great help!

Thanks everybody!
 
Old 01-05-2006, 02:36 AM   #8
amushtaq
LQ Newbie
 
Registered: Sep 2005
Posts: 17

Rep: Reputation: 0
Another good way to logout a user logged in via ssh is to
issue the following command, especially if you don't wanna kill all the processes owned by that user

ps -ef|grep sshd

this will list the sshd processes running for each user logged in, killing the sshd for a particular user will obviously log him out.
 
Old 01-05-2006, 06:19 AM   #9
generic_genus
Member
 
Registered: Oct 2005
Distribution: Gentoo Unstable
Posts: 51

Rep: Reputation: 15
Isn't this exactly what killall -u will do?
 
Old 01-05-2006, 11:43 AM   #10
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,977
Blog Entries: 11

Rep: Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879
Quote:
Originally Posted by generic_genus
Isn't this exactly what killall -u will do?
No; it would kill all his processes. E.g. if he had fired up some
CPU intense app as night-processing in a screen session you'd
kill that along with the login-shells.

But that said:
killall -V
What do you get?

Because my killall doesn't know a -u option, I'd be using
skill -u user -c command


Cheers,
Tink
 
Old 01-05-2006, 12:00 PM   #11
amushtaq
LQ Newbie
 
Registered: Sep 2005
Posts: 17

Rep: Reputation: 0
killall has no option to kill processes by the user name instead you have to give the process name.
 
Old 01-05-2006, 12:27 PM   #12
generic_genus
Member
 
Registered: Oct 2005
Distribution: Gentoo Unstable
Posts: 51

Rep: Reputation: 15
killall does have an option to kill by username, killall -u foo, kills all of user foos processes logging them out in effect. I have now noticed the difference of doing "ps -ef|grep sshd", I'm sorry for the misunderstanding it appears I didn't even read the command as I believed it did something entirely different so now I'ver made a fool of myself :P I'll blame the late hour.

P.S the version info for killall as requested, what version are you using then?

killall (PSmisc) 21.9
Copyright (C) 1993-2005 Werner Almesberger and Craig Small
 
Old 01-05-2006, 01:10 PM   #13
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,977
Blog Entries: 11

Rep: Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879
An older one :}

Mine comes with procps-3.2.3, its version number is 21.4.

[edit]
I'm seriously confused now ...
I downloaded and installed the latest procps from
http://procps.sourceforge.net/download.html
(3.2.6) and my killall still doesn't have a
-u option ... what distro are you running? They're
obviously patching stuff into that program that the
original author didn't intend to be there. In fact,
a killall -V of the latest still gives a 21.4.
[/edit]


Cheers,
Tink

Last edited by Tinkster; 01-05-2006 at 01:39 PM.
 
Old 01-06-2006, 06:02 AM   #14
generic_genus
Member
 
Registered: Oct 2005
Distribution: Gentoo Unstable
Posts: 51

Rep: Reputation: 15
I'm running an unstable gentoo, and the version of prcps installed is 3.2.6. Looking at the installation output there are no patches applies whose name would suggest adding this functionality, only ones for solving build issues on different architectures adn some unrelated features. And the source package is the same as the version downloaded off procps homepage (compaing md5sums), perhaps configure flag settings? though I don't see why this would cause the version change. This is a bit weird.

if your interested these are the patches applied:

emerge procps
* Applying 3.2.5-top-sort.patch ... [ ok ]
* Applying procps-3.2.5-proc-mount.patch ... [ ok ]
* Applying procps-mips-define-pagesize.patch ... [ ok ]
* Applying procps-3.2.6-mips-n32_isnt_usable_on_mips64_yet.patch ... [ ok ]

Last edited by generic_genus; 01-06-2006 at 06:09 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
connecting to a local X session remotely? SocialEngineer Linux - Networking 6 12-23-2004 01:27 AM
Starting program remotely and have them continue to run after the session is ended OJAtkinson Linux - General 2 12-07-2004 12:06 PM
Opening a linux session remotely from windows? WarrenWright Linux - Newbie 12 02-04-2004 10:24 PM
How do you continue a session remotely? cdccarson Linux - General 4 09-08-2002 09:10 PM
jvm won't terminate beccala33 Linux - Newbie 0 05-14-2002 11:57 AM


All times are GMT -5. The time now is 12:29 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration