1833541 Members
3085 Online
110061 Solutions
New Discussion

Re: booting off users

 
SOLVED
Go to solution
JOHN TURNER_2
Frequent Advisor

booting off users

morning,

can someone please tell me how you go about logging out users that are on the system.

thanks
john
GUI's are for wimps!
9 REPLIES 9
Arunvijai_4
Honored Contributor
Solution

Re: booting off users

Hi John,

You can kill the user's telnet or ssh sessions.
That is the simplest way of doing.

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
Tiziano Contorno _
Valued Contributor

Re: booting off users

Hi John, -ksh lines refers to the session you should kill.

ps -ef | grep "$(who | awk '{print $2}')"
root 3484 924 0 12:58:08 pts/tc 0:00 telnetd
root 22452 924 0 10:43:23 pts/tb 0:00 telnetd
root 3485 3484 0 12:58:08 pts/tc 0:00 -ksh
root 4168 3485 1 13:01:57 pts/tc 0:00 awk {print $2}
root 4167 3485 1 13:01:57 pts/tc 0:00 ps -ef
root 22453 22452 0 10:43:23 pts/tb 0:00 -ksh
root 4169 4168 1 13:01:57 pts/tc 0:00 who
Muthukumar_5
Honored Contributor

Re: booting off users

Simply as,

get the process ID of user login as,

# who -u

will give the PID field number 7. Kill it as,

# kill -9

--
Muthu
Easy to suggest when don't know about the problem!
Yogeeraj_1
Honored Contributor

Re: booting off users

hi john,

you can run who -u

then kill -15 the PIDs

see also:

http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=622529


kind regards
yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
Carlos Roberto Schimidt
Regular Advisor

Re: booting off users

Hi, before kill the users process i think is better look for process running:

# ps -efl | grep -v root
Arunvijai_4
Honored Contributor

Re: booting off users

Hi John,

You can also stop ssh daemon and telnetd from /etc/inetd.conf,

# /sbin/init.d/secsh stop
# commenting out,

# telnet stream tcp nowait root /usr/lbin/telnetd telnetd


This will ensure that, no one can login further .

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
Senthil Kumar .A_1
Honored Contributor

Re: booting off users

Hi,

You can "su" as the user ID. and run the command "kill -9 -1"

ex:

# su - user1
$ kill -9 -1
#

Advantage with this method is, you do not require to search for all the tty's the user has logged into. Because there are scenarios wherein the user would have logged in multiple times through different tty's.

"kill -9 -1" will take care in killing all the process the user has spawned.

Regards,
Senthil Kumar .A
Let your effort be such, the very words to define it, by a layman - would sound like a "POETRY" ;)
Pete Randall
Outstanding Contributor

Re: booting off users

John,

A word of caution: grepping for user id's can lead to unwanted results because grep returns every match available.

A far better and safer way is to run something like this:

PROCESSES=`UNIX95= ps -U $USERNAME | grep -v PID |awk '{ print $1 }' | sort
-n`
for PROC in $PROCESSES
do
echo "\tKilling process $PROC"
kill -15 $PROC
sleep 1
kill -9 $PROC
done

Note that I have done a kill -15 to allow the process a chance to terminate normally and release its resources before resorting to the more brutal kill -9.


Pete

Pete
Richard Darling
Trusted Contributor

Re: booting off users

Hi John,
Why do you want to "logout" the user?

If the user were chronically not logging out correctly I would discuss the issues with him/her. I have found that some users think that by simply "hitting the X in the upper right-hand corner is the same as logging out" to quote an email reply I received from one user. So sometimes it is just a matter of education.

If it is a careless user I would discuss it with his/her supervisor, and use the stick of disabling the user's account if the continue to be careless.

As mentioned in above posts, be cautious in killing a process, as you may get undesirable results, especially if it is an application session. Examples of this could be locked records, incomplete updates, etc.

Richard