LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Bash scriptting related (https://www.linuxquestions.org/questions/linux-newbie-8/bash-scriptting-related-184620/)

Menestrel 05-22-2004 05:20 PM

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) )

HadesThunder 05-22-2004 06:48 PM

add new user in your gui then lgin as that user. Better still type chmod 777 [file]
Then try it.

Dark_Helmet 05-22-2004 07:22 PM

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.


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