LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 03-19-2004, 04:53 AM   #1
sanjith11
Member
 
Registered: Oct 2003
Distribution: redhat
Posts: 63

Rep: Reputation: 15
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
 
Old 03-19-2004, 08:29 AM   #2
Bebo
Member
 
Registered: Jul 2003
Location: Göteborg
Distribution: Arch Linux (current)
Posts: 553

Rep: Reputation: 30
I think su should work. Like su otheruser, or su - otheruser
 
Old 03-19-2004, 09:39 AM   #3
sanjith11
Member
 
Registered: Oct 2003
Distribution: redhat
Posts: 63

Original Poster
Rep: Reputation: 15
Unhappy

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 .
 
Old 03-19-2004, 09:54 AM   #4
Bebo
Member
 
Registered: Jul 2003
Location: Göteborg
Distribution: Arch Linux (current)
Posts: 553

Rep: Reputation: 30
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.
 
Old 03-22-2004, 07:25 AM   #5
dxdad
Member
 
Registered: Aug 2003
Distribution: Slackware
Posts: 75

Rep: Reputation: 15
You can run files as the owner of the file if you set the permissions in a certain way, can't you?
 
Old 03-22-2004, 09:19 AM   #6
Cruger
LQ Newbie
 
Registered: Mar 2004
Posts: 14

Rep: Reputation: 0
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
 
Old 03-22-2004, 01:18 PM   #7
Bebo
Member
 
Registered: Jul 2003
Location: Göteborg
Distribution: Arch Linux (current)
Posts: 553

Rep: Reputation: 30
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
help changing case on arguments to bourne shell script Maldain Programming 2 05-03-2005 10:18 AM
Shell script user input tuckermaddox Linux - Newbie 5 08-12-2004 03:14 AM
changing the user inside a shell script sanjith11 Programming 2 04-22-2004 07:44 AM
Shell script that changes user davholla Linux - General 2 03-23-2004 09:18 PM
shell script user not ok slam Linux - General 4 07-24-2003 06:40 AM


All times are GMT -5. The time now is 06:19 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration