Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'd like to add custom startup commands (for example starting a process, registering to a registration server, downloading a configuration file) to the Linux startup process. Those commands should be triggered on startup only. What is the standard/appropriate way to do this?

EDIT: Is /etc/profile the right place to trigger such things?

EDIT2: I'm using Ubuntu.

share|improve this question

migrated from Jun 9 '11 at 11:12

This question came from our site for professional and enthusiast programmers.

/etc/profile is for starting a new terminal session; it has nothing to do with booting. – chrisaycock Jan 11 '11 at 16:21
Linux is developed in a decentralized manner. The people who write your init scripts are quite separate from the people who write your kernel. As such, different distributions have different init scripts. – asveikau Jan 11 '11 at 16:23
Startup of what? Do you mean "during or after boot"? Do you mean "During or after I log in"? If log in, do you mean "log in to a local terminal"? Do you mean "Log in via a remote shell"? Do you mean "Log in from [xkg]dm"? Do you mean "Start up X"? – phogg Jan 11 '11 at 18:34
Linux is a kernel. You and I run an operating system that uses a Linux kernel, Gnu libraries and tools, X11 Windowing system, Gnome this and Openoffice that. As all (most) of there components fulfilling the Gnu project (Gnu is a meta project to make all software be Free Software), we can call the operating systems Gnu with Linux or Gnu/Linux (There are other systems that use Linux, and other kernels that can be used with Gnu). – richard Jan 24 '13 at 13:32
up vote 3 down vote accepted

No-one can answer this question without knowing which flavour of Linux you are using.

Under Debian (and Debian-based system such as Ubuntu), you put your startup script called foo to the directory /etc/init.d, then you call update-rc.d foo defaults. Be sure to consult the man page before so you understand what is happening.

share|improve this answer

The init system handles startup. That said, however, this question belongs on or

share|improve this answer
Most system use init, however, for example Slackware uses /etc/rc.d/* system but still support use of init! – user32178 Jan 11 '11 at 17:51
Another example: Ubuntu uses Upstart. – Dennis Williamson Jan 11 '11 at 20:20
@Dennis Williamson, they don't even support init scripts? – user32178 Jan 11 '11 at 21:24
@Anders: Upstart has legacy support for init scripts. – Dennis Williamson Jan 11 '11 at 21:32
No, the question doesn't belong on superuser or serverfault; it is a legitimate programming question which people packaging software for Linux need to know the answer to. – MarkR Jan 12 '11 at 8:10

One simple place where to put your script (although not all distributions use it) to be run at system boot time is /etc/rc.local

share|improve this answer

It depends exactly which distribution you're using. On redhat-like systems, you place your service file in /etc/init.d then use chkconfig --add to add it, and it will start up on boot at the appropriate time.

Some Linux systems also have a "cron" which supports the @reboot extension which runs the job when the system starts up. You can install crontabs using "crontab" or (as a very useful Redhat extension) in directory /etc/cron.d. See man(5) crontab, man(8) cron and man(1) crontab for more details.

If it's a constantly-running process, I'd install it as a sysv-style service.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.