Home > Articles > Home & Office Computing

  • Print
  • + Share This
This chapter is from the book

This chapter is from the book



Windows users who are moving to Linux often wonder how to get programs to start up automatically when the computer is turned on. Linux provides plenty of places where you can start your own programs. The technique you choose depends on when in the boot process you want the program to run. For example, you can launch processes before any users have logged in by adding a line to the rc (run command) scripts. Or wait until X is running by putting the command in a window manager's startup folder. Here are a few useful techniques for getting your own processes to start automatically.

Tame the Daemons

Daemons and other processes that need to run the entire time the machine is on should be started at bootup—even before any user has logged in. As usual, there's more than one way to do that. On Red Hat systems, turn common daemons on and off by logging in as root and running ntsysv at the command line. If you're running X, you can use tksysv. Both programs can start or stop common services like Web servers, print services, cron, and so on.

Add It By Hand

If the program or service you want to start isn't in the default ntsysv list, you can add it by hand to /etc/rc.d/rc.local. This shell script runs after the other init scripts but before any users have logged in. This is where you'd commonly start a firewall or proxy server.

Start with the Command Line

You can also start a program when the command line shell is started. To start a program for all users, modify the /etc/profile script. (If you're not using bash as your shell, you should read the man pages for the shell you do use to see what configuration files it checks when it starts up. Use the command man <shell name> to read the manual pages for that shell. For example, tcsh checks the /etc/csh.cshrc and /etc/csh.login files instead of /etc/profile.)

A Startup Program for Every User

There's a startup program for each user, too. In the bash shell, modify the user's ~/.bashrc file. (Note that tcsh uses the ~/.tcshrc file.) You'd most commonly use these files to add command line aliases, modify prompts, and the like, but any shell command can be placed there.

  • + Share This
  • 🔖 Save To Your Account