Operating System - HP-UX
1820879 Members
5149 Online
109628 Solutions
New Discussion юеВ

Logging out a user from the command line

 
SOLVED
Go to solution
Andrew Kaplan
Super Advisor

Logging out a user from the command line

Hi there --

There is a user account, test, on one of our servers, HP-UX 11.11, that has been idle for some time, and I want to log off the system.

Do I need to use the su - command syntax to switch to that user to do the log off, or is there another command that I can run as root to accomplish this task.

One approach I thought of using ps in conjunction with the kill command.
A Journey In The Quest Of Knowledge
11 REPLIES 11
James R. Ferguson
Acclaimed Contributor
Solution

Re: Logging out a user from the command line

Hi Andrew"

To use 'su' you would have to be running the session you want to eliminate, so that makes no sense.

I presume that the user's session was aborted from his/her end by an abortive disconnect (of a PC emulator). Simply 'kill' the pid that represents the old, idle session. You may need to do a 'kill -9 ' though it's good practice to start with a simple 'kill' and then a 'kill -HUP' first.

Regards!

...JRF...
Andrew Kaplan
Super Advisor

Re: Logging out a user from the command line

Hi there --

Thanks for your reply. I ran the ps command with the grep test and -u test syntaxes, and while they showed processes owned by the test user account, they did not show the pid for the user session.

What would the correct syntax be to determine the pid for the user session? Thanks.
A Journey In The Quest Of Knowledge
James R. Ferguson
Acclaimed Contributor

Re: Logging out a user from the command line

Hi (again):

> What would the correct syntax be to determine the pid for the user session?

# who -u

...will show you login sessions (which is what I assume you see as "idle".

Regards!

...JRF...
Steven Schweda
Honored Contributor

Re: Logging out a user from the command line

> I ran the ps command [...]

Which you can't show here?

> [...] they showed processes [...]

Not to me.

> [...] determine the pid for the user
> session?

Did you look at the parent PID (PPID) for any
of these processes? (If my psychic powers
were stronger, then perhaps I could see what
you see, and that might save us some
back-and-forth. Or, you could show an actual
command with its actual output, instead of
providing only a vague description. Just a
thought.)
P Muralidhar Kini
Honored Contributor

Re: Logging out a user from the command line

Hi Andrew,

Get the PID of the process and terminate it.

* Get the pid of the process you want to kill
#who -u

* kill the process
#kill -9

Hope this helps.

Regards,
Murali
Let There Be Rock - AC/DC
Andrew Kaplan
Super Advisor

Re: Logging out a user from the command line

Hi there --

I ran the who -u command, and the output is shown below:

root pts/ta Jun 23 12:27 . 29986 w0081861.mgh.harvard.edu
test pts/8 Feb 4 14:32 old 27074 mgh-9044a375d1f.
test pts/10 Feb 4 14:37 old 29875 mgh-9044a375d1f.

The kill command was applied to the processes, 27074 and 29875 associated with the test user account. However both commands resulted in the "No such process" error message.

A Journey In The Quest Of Knowledge
James R. Ferguson
Acclaimed Contributor

Re: Logging out a user from the command line

Hi (again) Andrew:

> The kill command was applied to the processes, 27074 and 29875 associated with the test user account. However both commands resulted in the "No such process" error message.

Then this is a case of the 'utmp*' file which holds login information being corrupt --- not a "big deal". Things will get cleaned up at the next reboot.

Regards!

...JRF...
Andrew Kaplan
Super Advisor

Re: Logging out a user from the command line

Hi there --

Thanks for the information. We are planning on doing a scheduled reboot of the server in the next couple of weeks, so I will put the matter to rest for now.
A Journey In The Quest Of Knowledge
Sunil Kumar H G
Advisor

Re: Logging out a user from the command line

Hi Andrew,


Restart the UTMPD daemon using below commands:

#./sbin/init.d/utmpd stop
#./sbin/init.d/utmpd start

This should remove the invalid user entries.

Regards,
Sunil
Arvin E.
Frequent Advisor

Re: Logging out a user from the command line

Hi Andrew,

If you want to log out a user:

1- do a "w" and determine user,
2- under tty column of that user, see what pts?
3- do a "fuser -ku /dev/pts/3" with root if that user is in pts/3.

--arvin--
Pulse001
Regular Advisor

Re: Logging out a user from the command line

Simply identify the pid of the session by using the below command

#who -Hu

You will see something like this

NAME LINE TIME IDLE PID COMMENTS
root console May 17 11:05 old 2105 system console

Now use the pid to kill the session

# kill -9