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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
01-04-2006, 03:59 PM
|
#1
|
Member
Registered: Sep 2005
Location: California
Distribution: Slackware & Debian
Posts: 264
Rep:
|
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!
|
|
|
01-04-2006, 04:02 PM
|
#2
|
Moderator
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417
|
1) w
2) kill <pid>
|
|
|
01-04-2006, 05:19 PM
|
#3
|
Member
Registered: Oct 2005
Distribution: Gentoo Unstable
Posts: 51
Rep:
|
I'd use
killall -u <user>
|
|
|
01-04-2006, 05:44 PM
|
#4
|
Member
Registered: Sep 2005
Location: California
Distribution: Slackware & Debian
Posts: 264
Original Poster
Rep:
|
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?
|
|
|
01-04-2006, 05:47 PM
|
#5
|
Member
Registered: Oct 2005
Distribution: Gentoo Unstable
Posts: 51
Rep:
|
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.
|
|
|
01-04-2006, 08:36 PM
|
#6
|
Moderator
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
|
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
|
|
|
01-04-2006, 08:40 PM
|
#7
|
Member
Registered: Sep 2005
Location: California
Distribution: Slackware & Debian
Posts: 264
Original Poster
Rep:
|
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!
|
|
|
01-05-2006, 02:36 AM
|
#8
|
LQ Newbie
Registered: Sep 2005
Posts: 17
Rep:
|
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.
|
|
|
01-05-2006, 06:19 AM
|
#9
|
Member
Registered: Oct 2005
Distribution: Gentoo Unstable
Posts: 51
Rep:
|
Isn't this exactly what killall -u will do?
|
|
|
01-05-2006, 11:43 AM
|
#10
|
Moderator
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
|
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
|
|
|
01-05-2006, 12:00 PM
|
#11
|
LQ Newbie
Registered: Sep 2005
Posts: 17
Rep:
|
killall has no option to kill processes by the user name instead you have to give the process name.
|
|
|
01-05-2006, 12:27 PM
|
#12
|
Member
Registered: Oct 2005
Distribution: Gentoo Unstable
Posts: 51
Rep:
|
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
|
|
|
01-05-2006, 01:10 PM
|
#13
|
Moderator
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
|
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.
|
|
|
01-06-2006, 06:02 AM
|
#14
|
Member
Registered: Oct 2005
Distribution: Gentoo Unstable
Posts: 51
Rep:
|
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.
|
|
|
All times are GMT -5. The time now is 09:42 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|