LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-01-2012, 02:04 PM   #1
linuxino
LQ Newbie
 
Registered: May 2012
Posts: 16

Rep: Reputation: Disabled
disconnect when user double or multiple


Hello everyone, I tried searching on google but not finding answers, I decided to post an interesting topic I hope for you too. Having logged in "es. 4 user" on my Debian, eg. from 4 different locations all with the logged user "debian" from one of these positions as I can do a logout of a single host connected? I try to explain better: - 4 hosts connected to the Debian server as a "debian". - From one of these hosts using "who-to" visualize all user related, but all are "debian", if I want to disconnect, and of course stop the operation that was running as that user I can do? using pkill-u debian-kill me disconnettte them all. thanks
 
Old 06-02-2012, 01:04 PM   #2
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 8,104

Rep: Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267
probably you can use last to find out the tty connected to a given host and you need only to kill the processes of that tty.
 
Old 06-02-2012, 01:10 PM   #3
linuxino
LQ Newbie
 
Registered: May 2012
Posts: 16

Original Poster
Rep: Reputation: Disabled
you tell me how do I kill the process that interests me and how do I identify it?
 
Old 06-02-2012, 01:16 PM   #4
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 8,104

Rep: Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267
to identify you can use the command last. You may need to use grep/awk to find out the the important lines probably, you need to investigate what is the way you like.
 
Old 06-02-2012, 01:49 PM   #5
linuxino
LQ Newbie
 
Registered: May 2012
Posts: 16

Original Poster
Rep: Reputation: Disabled
And how kill the process ?
 
Old 06-02-2012, 02:08 PM   #6
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 8,104

Rep: Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267
there is a command to kill a process: kill (yes, this is the name).
 
Old 06-02-2012, 02:34 PM   #7
rosehosting.com
Member
 
Registered: Jun 2012
Posts: 222

Rep: Reputation: 62
Quote:
Originally Posted by linuxino View Post
Hello everyone, I tried searching on google but not finding answers, I decided to post an interesting topic I hope for you too. Having logged in "es. 4 user" on my Debian, eg. from 4 different locations all with the logged user "debian" from one of these positions as I can do a logout of a single host connected? I try to explain better: - 4 hosts connected to the Debian server as a "debian". - From one of these hosts using "who-to" visualize all user related, but all are "debian", if I want to disconnect, and of course stop the operation that was running as that user I can do? using pkill-u debian-kill me disconnettte them all. thanks

You can start by using 'last' as suggested by @pan64 in order to find the the tty and the location of users. For example:

Code:
└─ last | head | grep ^d
d        pts/9        host/ip Sat Jun  2 20:13   still logged in
d        ssh          host/ip Sat Jun  2 20:13   still logged in
=> d        pts/8        host/ip Sat Jun  2 20:13   still logged in <=
d        ssh          host/ip Sat Jun  2 20:13 - 20:13  (00:00)
d        pts/7        host/ip Sat Jun  2 20:13   still logged in
d        ssh          host/ip Sat Jun  2 20:13 - 20:13  (00:00)
then you can get the processes executed by your user, by executing:

Code:
└─ ps -fu d
UID        PID  PPID  C STIME TTY          TIME CMD
d        17943 17917  0 Mar23 ?        00:00:00 sshd: d@pts/7
d        17946 17943  0 Mar23 pts/7    00:00:00 -bash
d        17987 17973  0 Mar23 ?        00:00:00 sshd: d@pts/8
d        17993 17987  0 Mar23 pts/8    00:00:00 -bash
d        18021 18001  0 Mar23 ?        00:00:00 sshd: d@pts/9
d        18022 18021  0 Mar23 pts/9    00:00:00 -bash
d        18858 17993  0 Mar23 pts/8    00:00:00 vim /home/d/example.txt
** in this example my user is 'd'.

so let's say I want to kill the session for the user 'd' logged in from 'host/ip', using the tty 'pts/8' which is running 'vim' for example. I would kill the '-bash' process which will kill user's session.

Code:
└─ kill -9 17993
or better yet you may want to send a SIGHUP (-HUP switch) to the PID instead of killing it with '-9' priority, because this will allow them to exit gracefully.
 
Old 06-02-2012, 05:24 PM   #8
linuxino
LQ Newbie
 
Registered: May 2012
Posts: 16

Original Poster
Rep: Reputation: Disabled
works, thank you very much. Meanwhile, if there are other solutions let me know.
 
Old 06-03-2012, 05:12 AM   #9
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 8,104

Rep: Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267
so you have a solution? Is this ok, or you have still some troubles? Why do you need another solution?







__________________________________
Happy with solution ... mark as SOLVED
If someone helps you, or you approve of what's posted, click the "Add to Reputation" button, on the left of the post.
 
Old 06-03-2012, 06:08 AM   #10
linuxino
LQ Newbie
 
Registered: May 2012
Posts: 16

Original Poster
Rep: Reputation: Disabled
sorry I said bad I say it's perfect, but if you can do the same thing with other operations. just out of curiosity. thanks
 
  


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
multiple module loads from /etc/modules without device disconnect rymjones222 Linux - Hardware 1 05-14-2012 04:21 PM
creating multiple user in multiple linux boxes from single remote host niaz_ph Linux - Newbie 3 09-12-2011 04:48 PM
LXer: Microsoft aims to double user base with $3 Windows and Office LXer Syndicated Linux News 0 04-19-2007 12:32 PM
How to disconnect user from list sajidmumtaz Solaris / OpenSolaris 6 06-22-2006 02:01 AM
How t disconnect an SSH'd user? DarkElf109 Linux - Networking 2 01-20-2006 10:57 PM


All times are GMT -5. The time now is 12:17 PM.

Main Menu
Advertisement
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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration