cancel
Showing results for 
Search instead for 
Did you mean: 

Restricted command

 
SOLVED
Go to solution
suju
Advisor

Restricted command

How a normal user can run a script of (containing root privileaged commands) in profile or .profile
So that the owner of the process (script
#ps -aef |grep scriptname) will be root
The script should run in the background.
Need ur help
Thanks in advance.
4 REPLIES
Autocross.US
Trusted Contributor
Solution

Re: Restricted command

This can be done with sudo.

Run this command to edit the sudoers file:
visudo

Add something like this (for 'user1' as example):
user1 ALL = NOPASSWD: /path/to/script.sh

Then in the user1 .profile, add this:
sudo /path/to/script.sh &

This will run the command as root in the background. For more information on sudo:

http://www.gratisoft.us/sudo/
I drive way too fast to worry about calories.
OldSchool
Honored Contributor

Re: Restricted command

so, you have some script, lets say "a", and
1) you want to run that during the login process
2) as "root"
3) in the background???

you might (and its not guaranteed to work), set the suid bits on the script in question and make the owner of the script "a" root. HOWEVER, in most cases, the OS will ignore suid on shell scripts (as I recall). AND, even if it works now, it might not in the future.

sudo should allow you to specify that *anybody* can run that specific script w/o requiring a password, and thus might be a viable option.

If you state what the goal of this, rather then how you intend to implement it, you might get better responses.
suju
Advisor

Re: Restricted command

Thanks all
I'll try it out, But regarding sudo, I am using Hpux9.0, & I dont have sudo installed
and dont know whether sudo is available/compatible for this verion of Hp-ux.

Thanks
Avinash20
Honored Contributor

Re: Restricted command

Yes, it compatible
http://www.gratisoft.us/sudo/install.html

and you could download the source code
http://hpux.asknet.de/hppd/hpux/Sysadmin/sudo-1.6.9p19/
"Light travels faster than sound. That's why some people appear bright until you hear them speak."