LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   running programs as root (https://www.linuxquestions.org/questions/linux-general-1/running-programs-as-root-189389/)

mehesque 06-03-2004 03:47 PM

running programs as root
 
I'm using RH AS 3.0 at the moment. My intention is to automate a testing process. For this I'll need to automate the logon process and the kickoff of a few scripts.
I guess I have three questions.

1) I'm able to automatically logon as a standard user using one of RH's options but is there a way to logon automatically as root? I won't have to logon as root if #2 can be answered, but I would rather do it this way.

2) I have some proprietary programs that only run under root. I tried using the sticky bit on these but I guess that I don't understand that concept properly as they still won't run.

3) If i wanted to cascade a few scripts--after one finishes, the next one can go. Do I just list them in the /init/rc.d/local directory or is there a cleaner way?

Thanks a lot.

david_ross 06-03-2004 03:50 PM

1) If I assume that you are running these at boot since you ask about rc directories in 3 - then the scripts will run as root by default.

3) If you want them to run at boot then rc.local should be fine. If you want to make sure that command1 exists successfully before running command2 then you can use:
command1 && command2

mehesque 06-03-2004 03:53 PM

My mistake that would be /etc/rc.local.

mehesque 06-03-2004 03:55 PM

I forgot to mention that I want to do this at run level 5.

david_ross 06-03-2004 03:59 PM

If you only want to do it at runlevel 5 then don't use rc.local. Create a new script in init.d and symlink it as a startup script to the runlevel 5 folder.

mehesque 06-03-2004 04:26 PM

Thanks for the info and the quick responce.

However, I don't think it ran for some reason. I also noticed a "INIT: open(/dev/console): Input/output error" during bootup. Is this out of the norm?

mehesque 06-07-2004 01:41 PM

I've tried put a script in the init.d directory with a S99 sysmlink in rc5.d. I'm not sure if that's the way to do it--besides the fact it's not working for me.

What I'm trying to kick off isn't a daemon, it's simple a stand-alone program. I just want it to automatically input a shell command with a few options and switches and it run on boot up as root.

Thanks for the quick response last time.

mehesque 06-08-2004 11:07 AM

Any help would be very much appreciated, I'm getting a little desperate.

Thanks.

david_ross 06-08-2004 12:23 PM

I assume that you are booting to runlevel 5?

mehesque 06-08-2004 01:34 PM

Yes I am booting to runlevel 5, sorry about the delay.

ssba 06-08-2004 02:09 PM

As for #2, you can try running the programs under sudo (man sudo), which basically runs programs with root privileges while under a normal user..

mehesque 06-08-2004 02:37 PM

Basically I don't think the issue is root, I think it's about how do I run a command from rc5.d in runlevel 5. The init script doesn't have a fully functional daemon.

I just want to run some commands once everything is up and running.

Much like running a batch file placed in the startup folder in Windows....

ssba 06-08-2004 04:07 PM

well, if you want the programs to start when your computer is finished booting (before X / GUI), you can *usually* add them (each on a separate line) to /etc/rc.d/rc.local (or wherever your version of that is located at -- theres usually a file like that where you can put in your commands, i'm not sure where that is exactly in RH. /etc/init.d/rc.d/rc.local maybe? )

Or, if you want them to start when your X / GUI loads, you can add them, one command per line, to ~/.xinitrc

mehesque 06-09-2004 09:41 AM

Hey ssba thanks for the ~/.xinitrc suggestion I think that's the right direction. However, for some reason that isn't working.

I've sudo-ed all the programs so that that isn't my concern.

I've tried the command by itself, I've tried it appened on the end of the copied /etc/X11/xinit/xinitrc.

I'm using gdm(rh9.0) though, so should that affect anything?

ssba 06-09-2004 11:38 AM

Quote:

Originally posted by mehesque
Hey ssba thanks for the ~/.xinitrc suggestion I think that's the right direction. However, for some reason that isn't working.
It shouldn't effect anything, I'm pretty sure gnome uses .xinitrc as well. Does the file have executable permissions? Usually its 700 or 755.


All times are GMT -5. The time now is 01:35 PM.