Forcing a user to logout
Dear my friends... Please teach me which command line in the console which I can use to display which users are being logged in. They login through NIS. And please tell me which command line that I can use to kick the user out (forcing logout). If they login through NIS. If I login into a machine as a root with ssh (ssh -l root 192.168.23.1), can I force with command line the users which login locally to be log out? Thank you very much. __________________________________ Do you Yahoo!? SBC Yahoo! - Internet access at a great low price. http://promo.yahoo.com/sbc/
On Monday 17 May 2004 15.27, Prabu Subroto wrote:
Dear my friends...
Please teach me which command line in the console which I can use to display which users are being logged in. They login through NIS.
And please tell me which command line that I can use to kick the user out (forcing logout). If they login through NIS.
If I login into a machine as a root with ssh (ssh -l root 192.168.23.1), can I force with command line the users which login locally to be log out?
I've never seen a command to do it 'nicely', but each login has a 'mother process'. One which governs all the others. Usually it is X, if they log in graphically. If they log in from the command line it is one of the bash processes. If you do 'ps aux --forest' you can get a (more or less) graphical view of the tree structure. If you kill that top process for the user, he will be logged out. Note that this is not a 'nice' logout, so it may be that programs he has running won't have time to save their data etc, so use with caution
On Mon, May 17, 2004 at 06:27:28AM -0700, Prabu Subroto wrote:
Please teach me which command line in the console which I can use to display which users are being logged in. They login through NIS.
And please tell me which command line that I can use to kick the user out (forcing logout). If they login through NIS.
A simple who should tell you who's logged in. A ps should tell you which process is used to be logged in, and kill is always useful in kicking them off. Are these users not supposed to be able to log in or do you want to kick a certain type of user? Regards, Pieter Hulshoff
Pieter Hulshoff wrote:
On Mon, May 17, 2004 at 06:27:28AM -0700, Prabu Subroto wrote:
Please teach me which command line in the console which I can use to display which users are being logged in. They login through NIS.
And please tell me which command line that I can use to kick the user out (forcing logout). If they login through NIS.
A simple who should tell you who's logged in. A ps should tell you which process is used to be logged in, and kill is always useful in kicking them off. Are these users not supposed to be able to log in or do you want to kick a certain type of user?
Regards,
Pieter Hulshoff
Sometimes killing the root process (normaly /bin/bash) will still leave running processes. This is not very complete, however, it should work. Name it somthing like 'killuser' and run 'killuser username'. NOTE: This is mean ... unforgiving ... and sometimes fun (I did this to my wife ... just as she was about to win her card game ... ONCE ;-) ). #!/bin/bash echo echo "----------------------------------------------" echo Killing all processes owned by user $1 echo "----------------------------------------------" kill -9 `ps -u $1 -o "pid="` echo "----------------------------------------------" echo There are `ps -u $1 -o "pid=" | grep -c ""` processes left for user $1 echo "----------------------------------------------" echo -- Louis D. Richards LDR Interactive Technologies
On Mon, 2004-05-17 at 10:04, Louis Richards wrote:
Pieter Hulshoff wrote:
Sometimes killing the root process (normaly /bin/bash) will still leave running processes.
This is not very complete, however, it should work. Name it somthing like 'killuser' and run 'killuser username'. NOTE: This is mean ... unforgiving ... and sometimes fun (I did this to my wife ... just as she was about to win her card game ... ONCE ;-) ).
#!/bin/bash echo echo "----------------------------------------------" echo Killing all processes owned by user $1 echo "----------------------------------------------" kill -9 `ps -u $1 -o "pid="`
kill -9 is rather extreme isn't it. Try kill -1 first for a more graceful logout of the process and a better chance of the child processes being killed as well.
echo "----------------------------------------------" echo There are `ps -u $1 -o "pid=" | grep -c ""` processes left for user $1 echo "----------------------------------------------" echo
-- Ken Schneider unix user since 1989 linux user since 1994 SuSE user since 1998 (5.2)
On Mon, May 17, 2004 at 10:04:14AM -0400, Louis Richards wrote:
Sometimes killing the root process (normaly /bin/bash) will still leave running processes.
With the kill -9 you put in your script I think that's possible, but would a kill -HUP cause the same problem if you kill the parent process? Regards, Pieter Hulshoff
Pieter Hulshoff wrote:
On Mon, May 17, 2004 at 10:04:14AM -0400, Louis Richards wrote:
Sometimes killing the root process (normaly /bin/bash) will still leave running processes.
With the kill -9 you put in your script I think that's possible, but would a kill -HUP cause the same problem if you kill the parent process?
Regards,
Pieter Hulshoff
I think the previous sugestion of "kill -1" would work. The only time (other than to anger my wife) I have used this command was to clear a client that was locked up hard from some game that froze. I used "-9" and ran it a couple of times till nothing was left and the system came back to life. This was an extreme situation and admitedly overkill for "logging off" a user. Of course, we could always make this another parameter and let people try what they want. -- Louis D. Richards LDR Interactive Technologies
On Mon, 2004-05-17 at 09:27, Prabu Subroto wrote:
Dear my friends...
Please teach me which command line in the console which I can use to display which users are being logged in. They login through NIS.
w
And please tell me which command line that I can use to kick the user out (forcing logout). If they login through NIS.
kill -1 <pid of user session>
If I login into a machine as a root with ssh (ssh -l root 192.168.23.1), can I force with command line the users which login locally to be log out?
Only local logins or all logins? Normally root cannot ssh to a box for security reasons. You would need to ssh with a regular user and then su or sux or su - to root. -- Ken Schneider unix user since 1989 linux user since 1994 SuSE user since 1998 (5.2)
On Monday 17 May 2004 15:22, Kenneth Schneider wrote: <snip>
Only local logins or all logins?
Normally root cannot ssh to a box for security reasons. You would need to ssh with a regular user and then su or sux or su - to root.
Just a note: I routinely ssh to my home PC as root, so no problem there... 011
participants (6)
-
Anders Johansson
-
Fortean
-
Kenneth Schneider
-
Louis Richards
-
Pieter Hulshoff
-
Prabu Subroto