LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian
User Name
Password
Debian This forum is for the discussion of Debian Linux.

Notices

Reply
 
Search this Thread
Old 10-05-2011, 09:44 AM   #1
cccc
Senior Member
 
Registered: Sep 2003
Distribution: Debian Squeeze / Wheezy
Posts: 1,608

Rep: Reputation: 45
force logoff a user from the command line?


hi

If I try to remove a user accout using "userdel" or "deluser" command, then I get a message that this user is already logged in.
Howto force logoff a user from the command line on squeeze?

Last edited by cccc; 10-05-2011 at 02:55 PM.
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 10-05-2011, 10:07 AM   #2
tronayne
Senior Member
 
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,033

Rep: Reputation: 755Reputation: 755Reputation: 755Reputation: 755Reputation: 755Reputation: 755Reputation: 755
You can use
Code:
who
to see if the user actually is logged on.

You can also use
Code:
ps -ef | grep userid
You're looking for something that looks like this
Code:
userid     4354  4352  0 10:52 pts/1    00:00:00 /bin/sh -l
The process identification number is that first value. You can kill the PID with
Code:
kill -9 4354
The other thing you can do is kill all of the processes that user has going with
Code:
kill -9 `ps -ef | grep userid | awk '{print $2}'`
That'll kill any stray processes that user account may have open (or running). Note that this may produce error messages about missing processes because the user's shell will probably be the first to die (and that will make other processes die).

Hope this helps some.
 
2 members found this post helpful.
Old 10-05-2011, 02:54 PM   #3
cccc
Senior Member
 
Registered: Sep 2003
Distribution: Debian Squeeze / Wheezy
Posts: 1,608

Original Poster
Rep: Reputation: 45
Thx, I get the following:
Code:
# who
root     tty1         2011-10-05 16:37
root     pts/0        2011-10-05 21:43 (10.41.0.90)
# ps -ef | grep userid
root      2665  2646  0 21:49 pts/0    00:00:00 grep userid
# userdel --force myuser
userdel: Benutzer myuser ist derzeit angemeldet.
Benutzer myuser ist derzeit angemeldet => User myuser is currently logged on

Last edited by cccc; 10-05-2011 at 04:01 PM.
 
Old 10-05-2011, 03:03 PM   #4
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora, Lubuntu, FreeBSD
Posts: 3,930
Blog Entries: 5

Rep: Reputation: Disabled
Strange that he's not showing up in /var/log/utmp (who(1)) or the ps(1) output. Try:
Code:
# last | grep '^user_here' | head
... where user_here is his user name (not UID).

What does it tell you?
 
1 members found this post helpful.
Old 10-05-2011, 03:20 PM   #5
SL00b
Member
 
Registered: Feb 2011
Location: LA, US
Distribution: SLES
Posts: 375

Rep: Reputation: 111Reputation: 111
Quote:
Originally Posted by cccc View Post
Thx, I get the following:
Code:
# who
root     tty1         2011-10-05 16:37
root     pts/0        2011-10-05 21:43 (10.41.0.90)
# ps -ef | grep userid
root      2665  2646  0 21:49 pts/0    00:00:00 grep userid
# userdel --force sta
userdel: Benutzer sta ist derzeit angemeldet.
Benutzer myuser ist derzeit angemeldet => User myuser is currently logged on
In the previous advice, "userid" is a variable, not a literal. Substitute the ID of the user you're trying to remove for "userid."

So in your example, you're trying to get rid of user "sta", so:

Code:
ps -ef | grep sta
 
Old 10-05-2011, 03:23 PM   #6
frieza
Senior Member
 
Registered: Feb 2002
Location: harvard, il
Distribution: Ubuntu 11.4,DD-WRT micro plus ssh,lfs-6.6,Fedora 15,Fedora 16
Posts: 3,088

Rep: Reputation: 368Reputation: 368Reputation: 368Reputation: 368
should be simple
Code:
killall -u user
will kill all process owned by user 'user'
 
1 members found this post helpful.
Old 10-05-2011, 04:32 PM   #7
cccc
Senior Member
 
Registered: Sep 2003
Distribution: Debian Squeeze / Wheezy
Posts: 1,608

Original Poster
Rep: Reputation: 45
It's really strange why the process:

/usr/bin/gnome-keyring-daemon --myuserrt --foreground --components=secrets

is 2 times running, perhaps there is a problem?
Code:
# ps -ef | grep myuser
1000      1506     1  0 15:59 ?        00:00:00 /usr/bin/gnome-keyring-daemon --myuserrt --foreground --components=secrets
1000      1974     1  0 16:00 ?        00:00:00 /usr/bin/gnome-keyring-daemon --myuserrt --foreground --components=secrets
root      2692  2646  0 22:59 pts/0    00:00:00 grep myuser

Last edited by cccc; 10-06-2011 at 03:48 AM.
 
  


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
[SOLVED] Get a variable from a user on command line, in the middle of a line mikejreading Linux - Software 4 11-22-2010 09:06 PM
Add user from Command line darkapolloslx Linux - Newbie 1 12-29-2008 12:45 AM
How to get user Inactivity from command line kelo81 Linux - Security 1 02-27-2008 06:46 PM
Force logoff Harlin Linux - General 2 07-24-2005 09:35 PM
adding a user in the command line Daredevil Linux - Newbie 5 02-27-2004 12:56 PM


All times are GMT -5. The time now is 06:54 AM.

Main Menu
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