Democratic Underground Latest Greatest Lobby Journals Search Options Help Login
Google

Stupid Linux question

Printer-friendly format Printer-friendly format
Printer-friendly format Email this thread to a friend
Printer-friendly format Bookmark this thread
Home » Discuss » DU Groups » Computers & Internet » Open Source and Free Software Group Donate to DU
 
Deja Q Donating Member (1000+ posts) Send PM | Profile | Ignore Fri Sep-22-06 09:37 PM
Original message
Stupid Linux question
Boot-up batch file. I need to automatically run a command with root permissions so I don't have to manually type it in each boot.

How can I do this?

Thx!
Refresh | 0 Recommendations Printer Friendly | Permalink | Reply | Top
trotsky Donating Member (1000+ posts) Send PM | Profile | Ignore Sat Sep-23-06 10:01 AM
Response to Original message
1. What flavor?
Can you put a script file in /etc/rc.d or the equivalent for your OS?
Printer Friendly | Permalink | Reply | Top
 
Deja Q Donating Member (1000+ posts) Send PM | Profile | Ignore Sat Sep-23-06 01:03 PM
Response to Reply #1
3. SuSE 10.1...
Edited on Sat Sep-23-06 01:03 PM by HypnoToad
Thanks for the tip! I do have some experience with editing config files; I just find it easy to forget which ones at times. :dunce: One day I'll have everything memorized... by then I'll have wanted to have studied ActiveDirectory or something... :D


Printer Friendly | Permalink | Reply | Top
 
Tandalayo_Scheisskopf Donating Member (1000+ posts) Send PM | Profile | Ignore Mon Sep-25-06 11:41 PM
Response to Reply #3
4. sysv
n/t
Printer Friendly | Permalink | Reply | Top
 
bemildred Donating Member (1000+ posts) Send PM | Profile | Ignore Sat Sep-23-06 12:12 PM
Response to Original message
2. The previous fellow is correct.
You would use a shell script that is run by init at startup, usually kept in /etc/rc or /etc/rc.d or similarly named directories, perhaps called by a startup script in /etc. Unfortunately, in my experience, the arrangement of this functionality is one of the things that people like to fiddle with, so some assembly may be required to identify exactly how one ought to do it on your system.

You could try "man boot" or "man init" to start getting some clues.
Printer Friendly | Permalink | Reply | Top
 
longship Donating Member (1000+ posts) Send PM | Profile | Ignore Sat Nov-11-06 01:19 PM
Response to Reply #2
5. The standard location for scripts is /etc/init.d
Depending on your particular distribution (Red Hat, Ubuntu, Gentoo, etc.) there is a utility to update which boot scripts run at boot time. This is typically accomplished by updating links in /etc/rc.d

Your distribution should have specific instructions on how to do this.
Printer Friendly | Permalink | Reply | Top
 
MazeRat7 Donating Member (1000+ posts) Send PM | Profile | Ignore Wed Dec-27-06 09:30 PM
Response to Original message
6. Typically you put a post boot call to the cmd file in /etc/rc.d/init.d/rc.local
Be sure to background it if you don't want to wait for completion or its a non-terminating deamon.

MZr7
Printer Friendly | Permalink | Reply | Top
 
Recursion Donating Member (1000+ posts) Send PM | Profile | Ignore Sat Jan-06-07 11:08 PM
Response to Original message
7. In principle you don't want to touch /etc/init.d
Though that depends on your distro. If you just want command foo to run at boot-time, put

foo &

in /etc/rc.d/rc.local

The location of rc.local may vary; to find it for sure run

find /etc -name 'rc.local'
Printer Friendly | Permalink | Reply | Top
 
meldroc Donating Member (1000+ posts) Send PM | Profile | Ignore Wed Jan-10-07 05:25 PM
Response to Reply #7
8. rc.local is where you want to tinker.
Edited on Wed Jan-10-07 05:28 PM by meldroc
On Ubuntu systems, the file is /etc/rc.local, your location will vary, depending on your Linux distro.

/etc/init.d is where scripts are put to start up regular software, such as MySQL, all sorts of daemons, etc. It's built in a very specific way so sysv style init software knows how to deal with it. If you tinker in this directory, make sure you know exactly how things work in here, or you can break all sorts of stuff. Also, you may find that if you download updates to your distro, they may blow away any changes you make in this directory.

But rc.local is intended for user customizations, so you can put your boot-time commands here without too much hassle.
Printer Friendly | Permalink | Reply | Top
 
Recursion Donating Member (1000+ posts) Send PM | Profile | Ignore Sun Feb-25-07 02:09 PM
Response to Reply #8
9. I think FHS specifies /etc/rc.d/rc.local
and most distros that don't put it there satisfy that requirements with a symlink.

The important thing is not so much remembering that file X is in location Y but having a general idea of what a given file is expected to do (eg, rc.local is where local programs not administered by your distribution can be run on init).
Printer Friendly | Permalink | Reply | Top
 
qnr Donating Member (1000+ posts) Send PM | Profile | Ignore Fri Mar-02-07 04:33 PM
Response to Original message
10. Some other options:
Some distros will have an /etc/sysconf/bootmisc where you can enter commands to be run when you boot.

Also if you'd prefer to stay out of the actual init files, some versions of cron allow you to run commands at boot. Do a man 5 crontab and see if you have a time descriptor like @reboot
Printer Friendly | Permalink | Reply | Top
 
DU AdBot (1000+ posts) Click to send private message to this author Click to view 
this author's profile Click to add 
this author to your buddy list Click to add 
this author to your Ignore list Sun Dec 22nd 2024, 08:02 AM
Response to Original message
Advertisements [?]
 Top

Home » Discuss » DU Groups » Computers & Internet » Open Source and Free Software Group Donate to DU

Powered by DCForum+ Version 1.1 Copyright 1997-2002 DCScripts.com
Software has been extensively modified by the DU administrators


Important Notices: By participating on this discussion board, visitors agree to abide by the rules outlined on our Rules page. Messages posted on the Democratic Underground Discussion Forums are the opinions of the individuals who post them, and do not necessarily represent the opinions of Democratic Underground, LLC.

Home  |  Discussion Forums  |  Journals |  Store  |  Donate

About DU  |  Contact Us  |  Privacy Policy

Got a message for Democratic Underground? Click here to send us a message.

© 2001 - 2011 Democratic Underground, LLC