LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This 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.

Notices


Reply
  Search this Thread
Old 03-11-2005, 10:58 AM   #1
ziphem
Member
 
Registered: Feb 2004
Location: US / EU
Distribution: Fedora 31
Posts: 225

Rep: Reputation: 29
How to kill a user?


Hi, it happens once in a while that I log into my server, and then for some reason the connection is reset. I log in again, and see two "root" users; one which is the current session, the other which is the old session that got disconnected.

So my question is how to kill one of those sessios? I've tried killing pid of the user's ssh and bash, but to no avail. I finger my machine (I'm so immature) and still see both usernames there. Is there another way to kill one of the users, without rebooting?

Thanks!!
 
Old 03-11-2005, 11:48 AM   #2
perfect_circle
Senior Member
 
Registered: Oct 2004
Location: Athens, Greece
Distribution: Slackware, arch
Posts: 1,783

Rep: Reputation: 53
Re: How to kill a user?

Quote:
Originally posted by ziphem
Hi, it happens once in a while that I log into my server, and then for some reason the connection is reset. I log in again, and see two "root" users; one which is the current session, the other which is the old session that got disconnected.

So my question is how to kill one of those sessios? I've tried killing pid of the user's ssh and bash, but to no avail. I finger my machine (I'm so immature) and still see both usernames there. Is there another way to kill one of the users, without rebooting?

Thanks!!
This is what happens if a connection is lost, without properly logging out. You just kill the pid of the old bash.
if "kill <pid>" fails do "kill -9 <pid>" to send a sigkill instead of a sigterm signal. (sigterm can be ignored or caught by a process. Sigkill cannot be caught).
I used to have this problem with my university account. My INTERNET connections was bad, and sometimes It disconnected me. So in order to make the administrator's life easier, i logged back in and killed by myself the old processes.
 
Old 03-11-2005, 11:59 AM   #3
{BBI}Nexus{BBI}
Senior Member
 
Registered: Jan 2005
Location: Nottingham, UK
Distribution: Mageia 6, KDE Neon
Posts: 4,313

Rep: Reputation: 212Reputation: 212Reputation: 212
Alternatively issue a <who -u>, this will list users logged on along with the pid then do a kill -15 <pid> doing kill -9 straight away may not kill all processes for the user.
 
Old 03-11-2005, 04:05 PM   #4
benjithegreat98
Senior Member
 
Registered: Dec 2003
Location: Shelbyville, TN, USA
Distribution: Fedora Core, CentOS
Posts: 1,019

Rep: Reputation: 45
I just have to say that I love the title of your post. As a sysadmin I feel the same way sometimes!
 
Old 03-11-2005, 05:06 PM   #5
KimVette
Senior Member
 
Registered: Dec 2004
Location: Lee, NH
Distribution: OpenSUSE, CentOS, RHEL
Posts: 1,794

Rep: Reputation: 46
Quote:
Originally posted by benjithegreat98
I just have to say that I love the title of your post. As a sysadmin I feel the same way sometimes!
A 9mm is lightweight and easy to conceal, and is quiet as far as real handguns go, but if you know how to build a silencer you can probably do it with a 357 in only one shot and not garner too much unwanted attention. Just make sure you hide the body well afterward.

Seriously though - if you have multiple bash sessions running on that user's tty, you want to kill the bash process with the lowest PID.

--Kim
 
Old 03-11-2005, 07:09 PM   #6
ziphem
Member
 
Registered: Feb 2004
Location: US / EU
Distribution: Fedora 31
Posts: 225

Original Poster
Rep: Reputation: 29
Hehehehe thanks a lot for the response. The -15 didn't work, but the -9 did. Huh. The H&K USP .45 also did the trick, I tried that after kill -15 and before the -9. Ok seriously though, this is great, I've been trying to do this forever. I'm the only user, so it's just killing a session that got disconnected but still shows as active on the system rather than always rebooting.

Thanks very much again everyone for the quick answers, I really appreciate it.
 
Old 03-11-2005, 07:58 PM   #7
perfect_circle
Senior Member
 
Registered: Oct 2004
Location: Athens, Greece
Distribution: Slackware, arch
Posts: 1,783

Rep: Reputation: 53
Quote:
Originally posted by ziphem
Hehehehe thanks a lot for the response. The -15 didn't work, but the -9 did. Huh. The H&K USP .45 also did the trick, I tried that after kill -15 and before the -9. Ok seriously though, this is great, I've been trying to do this forever. I'm the only user, so it's just killing a session that got disconnected but still shows as active on the system rather than always rebooting.

Thanks very much again everyone for the quick answers, I really appreciate it.
Doing kill <pid> is the same as doing kill -15 <pid>. Kill is a command that sends a signal to a process. By default kill sends SIGTERM (the signal with value 15). Do
Code:
man 7 signal
to see all the existing signals. What you did is what the shutdown scripts in Linux/UNIX do. They send a SIGTERM(15) to all processes, they wait for a few seconds to let the processes end properly, and then they send a SIGKILL(9) signal, to terminate all the processes that did ignore the SIGTERM. If you pay attention to the output printed when your computer shuts down you'll notice it.

Quote:
Originally posted by benjithegreat98
I just have to say that I love the title of your post. As a sysadmin I feel the same way sometimes!
I've never been a sysadmin, but I know how you feel...Some people just should never be allowed to touch a keyboard.
 
Old 03-11-2005, 08:45 PM   #8
frob23
Senior Member
 
Registered: Jan 2004
Location: Roughly 29.467N / 81.206W
Distribution: OpenBSD, Debian, FreeBSD
Posts: 1,450

Rep: Reputation: 48
Guns work... sure. But have you ever cleaned cerebellum out of a keyboard? You just never know how a round object, as empty as the typical user's head, is going to react to the rapid introduction of a metal slug.

This is why my LART of choice is a classic oak "billie." This short club (a little over two feet in length) has the solid strength needed to put a user out of their misery for 20-30 minutes with one good blow. When further education is needed, it takes only a couple more blows to introduce a nice coma-like state. And for the final level of education, a good dozen blows to the cranium is not only effective but it strangely satisfying.

There is just no feeling like that of a user's head caving like a rotten pumpkin under the firm blows from your LART. It is that satisfaction which keeps me from the projectile weapons.


Last edited by frob23; 03-11-2005 at 08:48 PM.
 
Old 03-12-2005, 10:03 AM   #9
Lakefall
LQ Newbie
 
Registered: Feb 2005
Location: Finland
Distribution: Debian sarge
Posts: 26

Rep: Reputation: 15
You should apply the tips given here:
http://bofh.ntk.net/Bastard.html
http://www.theregister.co.uk/odds/bofh/

 
Old 03-12-2005, 10:30 AM   #10
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 269Reputation: 269Reputation: 269
My question would be, why are you logging directly in as root in the first place? Setup sudo or su if needed. And disable finger if your on a network...

And about the losing the connection to this server, run screen, it'll save you a lot of hassle. When you disconnect, you can reconnect and connect back to the same session you were on before.
 
Old 03-12-2005, 02:34 PM   #11
Not now, John!
Member
 
Registered: Jul 2004
Distribution: LFS 5.1
Posts: 161

Rep: Reputation: 30
pkill -u <user> should kill all processes started by <user>.
 
Old 03-12-2005, 06:55 PM   #12
KimVette
Senior Member
 
Registered: Dec 2004
Location: Lee, NH
Distribution: OpenSUSE, CentOS, RHEL
Posts: 1,794

Rep: Reputation: 46
*bleep* all that we've got to get on with these
Gotta compete with the wily Japanese
There's too many home fires burning
and not enough trees
so *bleep* all that
We've got to get on with these!

(great song, Not now, John!)
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I kill a user session? vous Linux - Security 3 03-20-2005 01:02 PM
Kill a user off line phiberoptik Slackware 10 11-24-2004 07:10 PM
kill idle user ust Linux - Software 3 08-31-2004 02:19 PM
How do I kill a user? phil1076 Linux - General 16 04-11-2004 09:11 AM
who idle user how to kill saavik Linux - Networking 1 03-04-2004 10:12 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 03:10 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
Open Source Consulting | Domain Registration