Showing results for 
Search instead for 
Did you mean: 

Restricted command

Go to solution

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.
Trusted Contributor

Re: Restricted command

This can be done with sudo.

Run this command to edit the sudoers file:

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

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

This will run the command as root in the background. For more information on sudo:
I drive way too fast to worry about calories.
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.

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.

Honored Contributor

Re: Restricted command

Yes, it compatible

and you could download the source code
"Light travels faster than sound. That's why some people appear bright until you hear them speak."