Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
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.
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.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
I'm really sorry to be asking what is surely an easy question, but 1) I have googled for hours and 2) I have searched through old forum posts and 3) I have pulled out a shell programming book and can't figure out how to do this. All I need to do is kill idle users that for some reason persist even though I'm no longer there.
If I run "who," for example, I get the following:
frog pts/1 Nov 30 15:38
turtle pts/2 Nov 30 16:10
turtle pts/3 Nov 30 16:13
turtle pts/4 Nov 30 17:09
frog pts/0 Nov 30 15:38
turtle pts/5 Nov 30 20:02
turtle pts/6 Nov 30 20:27
turtle pts/8 Nov 28 10:09 (remotelogin.zoolab)
"turtle" hasn't been at the zoolab for a day and a half, so why is he still showing up? AND, when I then use "who --all" to get a PID and try (even as root!) to kill it (kill -9 PID#), I get the message "No such process."
What other ways can I kill this idle instance of "turtle." Sometimes there are 30 or more!
Lastly, I know about "idled" but don't really know enough about changing the configuration files to try to get it to do that automatically. I just want to have a simple command line that I can type and kill these idle users whenever I want to.
Okay, that's a start, but the "who --all" seems to give me more info AND the PIDs. If I do "who -q" it just lists things like "frog turtle turtle turtle frog frog turtle turtle turtle turtle frog" and if I do the "ps -u turtle" then it gives me ALL the PIDs of ALL the turtles. What I need is a way to quickly kill the "turtle" on "pts/8" but NOT the turtle(s) that's logged in and active. I don't want to kill everything with turtle.
If I do "who --all" I get something like this:
LOGIN tty5 Nov 22 15:27 21925 id=5
LOGIN tty6 Nov 19 22:07 1235 id=6
... (more here)
turtle + pts/8 Nov 28 10:09 old 2882 (remotelogin.zoolab)
pts/9 Nov 29 20:59 14807 id=/9 term=0 exit=0
pts/10 Nov 30 15:16 30062 id=/10 term=0 exit=0
...(more here too)
It looks like 2882 is the PID for turtle on + pts/8. But if I try to "kill -9 2882" I get a "Cannot kill 2882...no such process" error.
So what is the syntax to kill JUST that one instance of turtle, the idle one on pts/8? Any ideas?
It's a bit obscure, but have a look at man wtmp. The "list of who's logged-on" can be fooled.
Use ps -uturtle to see if any processes, particularly bash, still exist which belong to this user-id. If so, you can kill the bash-processes (as root) and this should cause the user to be logged-off. (All of the processes spawned by the session will be direct or indirect descendents of his shell, and should die when it does.)
Thank you, Sundialsvcs, for that info. Interesting. Perhaps this pts/8 "turtle" isn't even there? It's just a phantom that "who" is reporting? That would explain why I'm getting the "can't kill the process, it doesn't exist" error.
Last question for you:
If I have 2 users, frog and turtle, and I _don't_ want to kill all instances of turtle but just a specific one (such as the one on pts/8, not tty3 or pts/1 or pts/2) is there a way to list JUST the bash shells that belong to pts/8? I'm worried that if I kill the wrong bash shell I'll kill the current (non-idle!) turtle instead of the old phantom one.
Lastly, can I clean up the "who" reporting? It doesn't look like I should mess with "wtmp" at all...but if "who" isn't reporting accurate info how do I fix that?