LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   changing user in a shell script (https://www.linuxquestions.org/questions/programming-9/changing-user-in-a-shell-script-159736/)

sanjith11 03-19-2004 04:53 AM

changing user in a shell script
 
hi all,
Is ther any way to change the user from a shell script without getting out of the script

Bebo 03-19-2004 08:29 AM

I think su should work. Like su otheruser, or su - otheruser

sanjith11 03-19-2004 09:39 AM

i know the command for changing user is su or sys .but su ask for a password so i cant use it. meanwhile for "sys -lu username" even though it switches user ,iam not able to run any commands as that user .

Bebo 03-19-2004 09:54 AM

Aha, but I don't think it is possible to change user without giving a password as other than root... Maybe you could use ssh, and set up public key authentication? See here.

dxdad 03-22-2004 07:25 AM

You can run files as the owner of the file if you set the permissions in a certain way, can't you?

Cruger 03-22-2004 09:19 AM

Is there a "default" password for root? My friend has installed Mandrake on his laptop but is logged in as a local user... so he can't access etc/shadow to see passwords

Bebo 03-22-2004 01:18 PM

dxdad, yes, you can use chmod to "set user or group ID on execution", as the man page puts it. With this set, you will run the application with permission(s) as the owner (chmod u+x) or group (chmod g+s) of the file. This is however, not recommended, for security reasons. At least when it comes to root-owned files.

Cruger, during the installation, Mandrake prompts for a root password. I don't know what Mandrake does if it isn't set. Maybe it's left empty; try su and see what happens - if the password is empty, then you should be let in at once. At least, I think so :) Otherwise, I think it's not that difficult to reset it. Unless I'm mistaken, give the option init=/bin/bash at the boot prompt and you should get a shell. Then use passwd to reset the password.


All times are GMT -5. The time now is 10:12 PM.