How do I make a program start when linux does?

Discussion in 'Installation/Configuration' started by Jrdgames, Jan 19, 2007.

  1. Jrdgames

    Jrdgames New Member

    How do I make a program start with linux? Or can I?
    OS is in signature.

  2. martinfst

    martinfst HowtoForge Supporter

    In the directory /etc you'll find a bunch of sub directories starting with rc. The numbers represent the so called run level. Default runlevel may vary per Linux variant. There's also a /etc/rc.local file, that's where I add my local commands, if you need it executed for all run levels.

    E.g. runlevel 1 is single user mode, no network, no mounted filesystems, only console. Sort of emergency level. Nowadays nobody cares much about the runlevels, everything is started. In the rc<0-6>.d directories, there are README files with more info.
  3. sjau

    sjau Local Meanie

    well, if you are using a gui environment then you can add programs to autostart in gnome/kde/xfce... or you can save a session which will be restored upon reboot...

    If you don't have a gui - so if you're just using it as server - you'll need to add the program to the according runlevels.
  4. falko

    falko Super Moderator

    On Ubuntu you must make sure that the init script of your program is in /etc/init.d, and that it is executable. Then you simply run
    update-rc.d [I]name_of_script[/I] defaults
  5. martinfst

    martinfst HowtoForge Supporter

    Now that's a trick I didn't know. Thanks for this pointer so I don't have to create all those stupid links myself anymore. I abused rc.local normally because I'm too lazy to do all the typing :p

Share This Page