LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 08-28-2007, 02:32 PM   #1
carlosinfl
Senior Member
 
Registered: May 2004
Location: Orlando, FL
Distribution: Arch
Posts: 2,902

Rep: Reputation: 73
Log Out a Specific User (KILL)


I created a test user simply with the "adduser" command and he is the only user on the machine except root obvioulsy but now I am trying to delete his account and it tells me that he is logged in so I can't delete him. I assumed my question was very basic so I did a Google search on how to log out a curently logged in user with out rebooting the box.

I found a page that referenced the "skill" command which I assumed was sig kill and I tried the following suggestions but it does not work. What am I doing wrong or is the problem the Linux box for some strange reason?

Code:
[root@lt2fs0 ~]# man skill
[root@lt2fs0 ~]# skill -KILL -u emery
[root@lt2fs0 ~]# users
emery root
[root@lt2fs0 ~]# skill -KILL -v /dev/pts/*
[root@lt2fs0 ~]# users
emery root
 
Old 08-28-2007, 03:02 PM   #2
XavierP
Moderator
 
Registered: Nov 2002
Location: Kent, England
Distribution: Lubuntu
Posts: 19,176
Blog Entries: 4

Rep: Reputation: 430Reputation: 430Reputation: 430Reputation: 430Reputation: 430
http://www.cyberciti.biz/tips/howto-...out-users.html may be of help
 
Old 08-29-2007, 07:15 AM   #3
carlosinfl
Senior Member
 
Registered: May 2004
Location: Orlando, FL
Distribution: Arch
Posts: 2,902

Original Poster
Rep: Reputation: 73
That was the exact page I pulled the commands from in my original thread for help. I don't understand why I get no response from this...

Perhaps I need to call Redhat support...?
 
Old 08-29-2007, 09:09 AM   #4
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957
In which way the user has looged in? If through ssh, you should be able to kill its login shell, e.g.
Code:
[root@linux ~]# who
colucix  :0           2007-08-27 09:58
colucix  pts/1        2007-08-29 12:26 (:0.0)
colucix  pts/2        2007-08-29 15:52 (name.domain.it)
[root@linux ~]# ps -u colucix | grep bash$
1420 pts/1    00:00:00 bash
7888 pts/2    00:00:00 bash
[root@linux ~]# kill -9 7888
[root@linux ~]#
Here the user I want to force logout has been allocated on pts/2 and the login shell is bash.
If the user logged in from a terminal, you can kill the X starting process, e.g.
Code:
[root@linux ~]# ps -u colucix
 7714 ?        00:00:00 gnome-session
 7774 ?        00:00:00 ssh-agent
 7777 ?        00:00:00 dbus-launch
 7778 ?        00:00:00 dbus-daemon-1
 7783 ?        00:00:00 gconfd-2
 ...
[root@linux ~]# kill -9 7714
[root@linux ~]#
A quite brutal approach, but it works for me!
 
Old 08-29-2007, 09:14 AM   #5
carlosinfl
Senior Member
 
Registered: May 2004
Location: Orlando, FL
Distribution: Arch
Posts: 2,902

Original Poster
Rep: Reputation: 73
Thanks for lending some info!

Perhaps I am doing something wrong...

Code:
[root@lt2fs0 home]# who
root     pts/0        Aug 29 08:13 (10.1.1.204)
emery    pts/1        Aug 28 15:07
[root@lt2fs0 home]# ps -u emery | grep bash$
ERROR: User name does not exist.
********* simple selection *********  ********* selection by list *********
-A all processes                      -C by command name
-N negate selection                   -G by real group ID (supports names)
-a all w/ tty except session leaders  -U by real user ID (supports names)
-d all except session leaders         -g by session OR by effective group name
-e all processes                      -p by process ID
T  all processes on this terminal     -s processes in the sessions given
a  all w/ tty, including other users  -t by tty
g  OBSOLETE -- DO NOT USE             -u by effective user ID (supports names)
r  only running processes             U  processes for specified users
x  processes w/o controlling ttys     t  by tty
*********** output format **********  *********** long options ***********
-o,o user-defined  -f full            --Group --User --pid --cols --ppid
-j,j job control   s  signal          --group --user --sid --rows --info
-O,O preloaded -o  v  virtual memory  --cumulative --format --deselect
-l,l long          u  user-oriented   --sort --tty --forest --version
-F   extra full    X  registers       --heading --no-heading --context
                    ********* misc options *********
-V,V  show version      L  list format codes  f  ASCII art forest
-m,m,-L,-T,H  threads   S  children in sum    -y change -l format
-M,Z  security data     c  true command name  -c scheduling class
-w,w  wide output       n  numeric WCHAN,UID  -H process hierarchy
 
Old 08-29-2007, 09:50 AM   #6
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957
Hmmm... really strange! What about
Code:
ps -lft pts\/1
to see what processes (if any) are associated to the pseudo-terminal of the (supposed) logged user?
 
Old 08-29-2007, 10:02 AM   #7
pwc101
Senior Member
 
Registered: Oct 2005
Location: UK
Distribution: Slackware
Posts: 1,847

Rep: Reputation: 128Reputation: 128
You could search for all processes not owned by root, and see if there's something still running from your test user:
Code:
ps -ef | grep -v root
Assuming it finds something, kill it and then try deleting the user again.
 
Old 08-29-2007, 10:11 AM   #8
carlosinfl
Senior Member
 
Registered: May 2004
Location: Orlando, FL
Distribution: Arch
Posts: 2,902

Original Poster
Rep: Reputation: 73
Quote:
Originally Posted by colucix View Post
Hmmm... really strange! What about
Code:
ps -lft pts\/1
to see what processes (if any) are associated to the pseudo-terminal of the (supposed) logged user?
Code:
[root@lt2fs0 ~]# ps -lft pts\/1
ERROR: TTY could not be found.
 
Old 08-29-2007, 10:53 AM   #9
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957
It sounds as - for some reason - the file /var/run/utmp has been not properly updated and all the applications that require a check for logged users are tricked (the who and users commands take info from this file). However it looks like the user emery has been deleted and pts/1 unallocated, since the ps command does not find them! You can easily verify these issues.
Furthermore, you can try the command last to see if emery is really still logged in, since in this case the file containing info is /var/log/wtmp. For example
Code:
[root@linux ~]# last
...
colucix  pts/5        :0.0             Wed Aug 29 15:43 - 15:50  (00:06)
colucix  pts/7        :0.0             Wed Aug 29 12:26   still logged in
...
Here, the first row tells about a closed session, the second one tells about a still open session. Also, the check suggested by pwc101 is worth a try.
 
  


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
Kill specific Wine program from Command Line Brian114 Linux - Software 4 06-07-2011 04:02 AM
kill specific process fj8283888 Linux - General 6 05-31-2007 06:28 AM
limit specific proces to a specific user Tux-Slack Linux - Software 3 02-23-2007 11:38 PM
how to kill specific python script melinda_sayang Linux - General 2 12-04-2005 03:31 AM
kill a specific session in windows rabeea General 8 12-15-2004 03:10 PM


All times are GMT -5. The time now is 01:45 PM.

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