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 |
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.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
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.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
08-28-2007, 02:32 PM
|
#1
|
|
Senior Member
Registered: May 2004
Location: Orlando, FL
Distribution: Debian
Posts: 2,860
Rep:
|
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
|
|
|
|
08-28-2007, 03:02 PM
|
#2
|
|
Moderator
Registered: Nov 2002
Location: Kent, England
Distribution: Lubuntu
Posts: 19,088
|
|
|
|
|
08-29-2007, 07:15 AM
|
#3
|
|
Senior Member
Registered: May 2004
Location: Orlando, FL
Distribution: Debian
Posts: 2,860
Original Poster
Rep:
|
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...?
|
|
|
|
08-29-2007, 09:09 AM
|
#4
|
|
Moderator
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.4 OpenSuSE 12.2
Posts: 9,897
|
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!
|
|
|
|
08-29-2007, 09:14 AM
|
#5
|
|
Senior Member
Registered: May 2004
Location: Orlando, FL
Distribution: Debian
Posts: 2,860
Original Poster
Rep:
|
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
|
|
|
|
08-29-2007, 09:50 AM
|
#6
|
|
Moderator
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.4 OpenSuSE 12.2
Posts: 9,897
|
Hmmm... really strange! What about
to see what processes (if any) are associated to the pseudo-terminal of the (supposed) logged user?
|
|
|
|
08-29-2007, 10:02 AM
|
#7
|
|
Senior Member
Registered: Oct 2005
Location: UK
Distribution: Slackware
Posts: 1,843
Rep: 
|
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.
|
|
|
|
08-29-2007, 10:11 AM
|
#8
|
|
Senior Member
Registered: May 2004
Location: Orlando, FL
Distribution: Debian
Posts: 2,860
Original Poster
Rep:
|
Quote:
Originally Posted by colucix
Hmmm... really strange! What about
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.
|
|
|
|
08-29-2007, 10:53 AM
|
#9
|
|
Moderator
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.4 OpenSuSE 12.2
Posts: 9,897
|
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.
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 08:13 PM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|