2

Newbie question:

I am planning to set up a Linux server (lightweight basic web, PIM server) "appliance", i.e. a tiny headless box. I would like it to start whenever I plug it in and switch on the power button, without having to do anything else or user interaction (hence "appliance").

Because of that, I am wondering if I need to login for the server services to start? Or would the server start running when the system loads, and no need for a specific user to login?

Thanks!

P.S. I might be installing an Ubuntu server, but the answer does not have to be Ubuntu-specific.

4 Answers 4

5

The thing you want to research are called "Runlevels". When a Linux device boots, it comes up to whatever the configured (or default) runlevel is, generally specified in the file /etc/inittab. For servers, that's commonly runlevel 3; for workstations, runlevel 5. The Init process handles the starting and stopping of services; no user login required.
For purposes of comparison, Windows basically has one runlevel, which corresponds to runlevel 5 in the Linux world.

What gets started and stopped are defined by the files in /etc/rcX.d, as ErikA explained. The X corresponds to the runlevel. Have a look at the tool "chkconfig" as an easy way to manipulate the settings for a given runlevel.

1
  • Evidently "sudo apt-get install chkconfig" will install it on Ubuntu, or you can build it from source. The truth is, I gave up on Debian when it wanted me to find 17 floppies to try it, so I'm not familiar w/ Ubuntu.
    – AndyN
    Sep 24, 2010 at 16:52
6

Yes, this not only possible, but is the default behavior in most cases. On your system, there will be a set of scripts in /etc/init.d/ and /etc/rcX.d that control the automatic startup of services.

1

Services will start irrespective of (and before any) user logins. I have a headless server running Ubuntu, and hardly ever log on to it (when I do, this normally happens via ssh since there's no keyboard/monitor).

P.S. I've used many distros over the years, and I think you're making the right choice going with Ubuntu.

1

As ErikA states, most services will have an init script that takes care of that. If your application doesn't have an init script, the best solution would be to write one for it. As a quick work-around, you can use cron with an entry like @reboot /path/to/something/to/run/when/server/starts But that way it will start without any extra interaction from you.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .