Ubuntu – Have a service start on startup with Ubuntu

avahiinit.dUbuntu

I'm not clear on how to start a service when the server boots, I read on some of the other questions asked about adding the script to /etc/init.d, but It's just one line that I need to execute in the commandline:

sudo /etc/init.d/avahi-daemon restart

But I have a few issues with this, firstly, I apparently need to use sudo, and it gives me the following:

ngl-server-01:~% sudo /etc/init.d/avahi-daemon start  
Rather than invoking init scripts through /etc/init.d, use the service(8)
utility, e.g. service avahi-daemon start

Since the script you are attempting to invoke has been converted to an
Upstart job, you may also use the start(8) utility, e.g. start avahi-daemon

But when I try just avahi-daemon start I get:

Too many arguments

Why is this? and how would you start this service?

Update

Similarly, how can I mount a disk on boot as well?

Best Answer

You can start the service manually by using

sudo start avahi-daemon

and not using

sudo avahi-daemon start

If you want it so the service starts at boot. You need to have a look at adding a symlink to /etc/rc2.d/ to point at /etc/init.d/avahi-daemon. It is probably easier to read up on the programs sysv-rc-conf or update-rc.d

For mounting a disk you need to edit /etc/fstab with the correct details. You need to know the device you are trying to mount (eg /dev/sdb1), the mount point (eg /mnt/data)and the filesystem.

The entry in fstab will look something like this:

/dev/sdb1    /mnt/data    ext3    defaults    0    2