Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 05-22-2004, 05:20 PM   #1
Registered: Oct 2003
Location: Bucharest
Distribution: Debian Sarge, Slackware Current, Ubuntu
Posts: 183

Rep: Reputation: 30
Bash scriptting related

How can I execute form within a script a program with a different user id ? ( I want to run a program like I'm another user (not root) )
Old 05-22-2004, 06:48 PM   #2
Registered: Mar 2004
Location: London
Distribution: Mandrake 9.1
Posts: 281

Rep: Reputation: 30
add new user in your gui then lgin as that user. Better still type chmod 777 [file]
Then try it.
Old 05-22-2004, 07:22 PM   #3
Senior Member
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 373Reputation: 373Reputation: 373Reputation: 373
I know of at least two options, with one more desirable than the other.

The first option is to make the program you want to run owned by the user you want to run it as, and then set the suid bit in it's permissions (man chmod). Whenever the program is run, it will run with the user id of the program's owner. This can get messy, especially if the program you're trying to run is a basic system utility (like ls, grep, etc.). This is really only an option for programs/scripts you have created yourself. Even then, it's not as clean a solution as below.

Take a look at the sudo package. Sudo will allow a user to execute commands as another user like you're hoping. However, out-of-the-box, it will ask you for the user's password before executing the command. With some tweaking of the configuration/privileges file, you can set it up so that a specific user or group of users need not enter the password to run a specific program. I would highly recommend this rather than the setuid bit above.


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
$LINENO can't be modified in bash 3.0, while it can be in bash 2.05b Darwish Linux - Software 1 11-07-2005 02:57 PM
bash related question Menestrel Linux - Newbie 2 01-25-2005 10:03 AM
bash + html + javascript or just bash ? rblampain Programming 4 12-01-2004 07:53 AM
why did bash 2.05b install delete /bin/bash & "/bin/sh -> bash"? johnpipe Linux - Software 2 06-06-2004 06:42 PM
bash related question MattSmith Linux - General 1 01-20-2004 05:41 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:36 PM.

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