Operating System - HP-UX
1834497 Members
2697 Online
110067 Solutions
New Discussion

switching between users logged-in

 
SOLVED
Go to solution
Maciej Szewczykowski
Frequent Advisor

switching between users logged-in

hi everybody.
i deal with HP workstation with the system HP-UX 11.0 running. there are two user accounts defined - i.e. user1 and user2. both use the same shell and belong to the same group (users). having logged-in as user1 i want to log in as user2 (using the command 'login'). the attempt results with fault, the system displays the following message: 'no utmp entry. you must exec "login" from the lowest level sh'. next the system continues work as user1. where is the problem?
2 REPLIES 2
Marco Santerre
Honored Contributor
Solution

Re: switching between users logged-in

Hi,

Instead of typing login why don't you try :

#exec login

Tha should ask you for a user ID and a password. Only when you exit you won't go back to user1 you'll just exit from the box. If you just want to go to user2 without losing user1's shell, I recommend you go using su

#su - user2
Cooperation is doing with a smile what you have to do anyhow.
Bill Hassell
Honored Contributor

Re: switching between users logged-in

What is happening is that the user1 shell runs the login command just like any other command, as a child process. login expects to run with no shell at all, thus the error message. The exec command tells the shell to replace itself with the login command, thus terminating the current shell and running login. An even faster way to switch users is:

exec login user2

and now, you'll just get a request for the password. su - user2 will accomplish the same goal EXCEPT it starts a subshell and unless user1 remembers to exit twice, there could be a long nested series of login shells.


Bill Hassell, sysadmin