LinuxQuestions.org
Review your favorite Linux distribution.
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 07-07-2006, 07:02 AM   #1
philippeP
LQ Newbie
 
Registered: Sep 2005
Location: Germany
Distribution: Debian sarge/etch
Posts: 18

Rep: Reputation: 0
Force logout of user. Cannot erase user account.


Hi,
I was trying a software in a new user profile "testuser". The software crashed. So I returned to my root shell, "satisfied" of my experience, and I want to erase "testuser" from my machine.

Quote:
# userdel -r testuser
userdel: user testuser is currently logged in
Indeed if I type "who" as root I get:
Quote:
# who
johnKdoe :0 Jul 7 09:07
testuser pts/1 Jun 28 19:55 (:0.0)
But "w" returns:
Quote:
# w
12:58:16 up 8 days, 17:09, 2 users, load average: 0.14, 0.22, 0.26
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
johnKdoe :0 - 09:07 ?xdm? 26:07 0.00s -:0
And I cannot find any process running for my "testuser" user. Pgrep returns nothing as run below...
Quote:
# pgrep -u testuser
#
Question: How can I force logoff of "testuser" so I can erase the corresponding account? Any idea how such a situation occurs?

Thanks for the help. Of course, I could reboot, but I am curious on how to solve this problem in a clean manner [i.e. not MS style ;-)]

Philippe
 
Old 07-07-2006, 10:46 AM   #2
MoMule
Member
 
Registered: Jul 2006
Posts: 134

Rep: Reputation: 15
Log Off User

Have you tried to su into the user, then type:

init 1

...do the deletion of the user as super user, then type:

init 5

?

Don't know if this is overkill or not, but you can try it (it's how we Linux people learn ).

Deion "Mule" Christopher
 
Old 07-07-2006, 07:56 PM   #3
gzickert
LQ Newbie
 
Registered: Feb 2004
Location: Orcutt, CA
Distribution: Fedora Core 10
Posts: 9

Rep: Reputation: 0
Smile Killing a user.

As root, enter "pkill -u <USER_NAME>". It will kill all processes owned by the USER_NAME.
 
Old 07-10-2006, 12:19 PM   #4
philippeP
LQ Newbie
 
Registered: Sep 2005
Location: Germany
Distribution: Debian sarge/etch
Posts: 18

Original Poster
Rep: Reputation: 0
Well since "pgrep -u testuser" does not return any process, it is with no big surprise that "pkill -u testuser" has not helped much more...

I haven't tried the "init 1" solution yet, since this would imply terminating my X session, wouldn't it? Nevertheless cleaner than reboot, but I would still be curious for something neeter.

Looking at another perspective of the problem: How does my Debian/Stable box checks if a user is logged in? Apparently not using "pgrep"... Anything I could try to play around with looking at this side of the problem?
 
Old 07-11-2006, 11:49 AM   #5
MoMule
Member
 
Registered: Jul 2006
Posts: 134

Rep: Reputation: 15
User Troubles

I found this script that might help out:

http://timvw.madoka.be/?p=416

here is the actual script:
------------------------------------------------

#!/bin/sh
#
# Author: Tim Van Wassenhove
# Update: 12-12-2003 13:15
#
# This script kills all processes that are owned by a given user.
#

if [ -n "1" ]
then
ps -ef | grep $1 | grep -v grep | awk { print } | xargs kill -9
else
echo "Usage: killuser.sh username"
fi

-------------------------------------------------

I just tested it on two users (one connected via VNC, and the other logged in locally. Both were killed with no problems...

Deion "Mule" Christopher
 
Old 07-12-2006, 12:22 PM   #6
philippeP
LQ Newbie
 
Registered: Sep 2005
Location: Germany
Distribution: Debian sarge/etch
Posts: 18

Original Poster
Rep: Reputation: 0
Anything based on "ps" "pkill" "pgrep" and so on, could not work since no process seem to be owned by the testuser user.

I have finally tried the "init 1" trick, and even that did not work.

Well now I have rebooted and got rid of my testuser [and got a new kernel up running :-)]

I guess the user was just registered in some file has being logged although he wasn't anymore (or caused by the original crash of the application).

Thanks nevertheless for the attempted help.
 
  


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
User Account to Access Another Account benfaust Linux - General 2 06-28-2006 01:26 PM
system account or user account??? yenonn Linux - Newbie 6 05-10-2006 08:49 PM
is it legitimate and allowed and can be done to make another user account set uid and gid to null 0 to make another root account with different name and possibly not damage the debian system creating and using that new account BenJoBoy Linux - Newbie 12 01-29-2006 11:02 AM
Force user login with different account rte Linux - Newbie 1 04-01-2004 10:09 AM
Force user ust Linux - General 1 10-09-2003 12:03 PM


All times are GMT -5. The time now is 08:55 AM.

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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration