In Ubuntu,

  1. Is there a command to show a list of all autostart services?
  2. Is there a command to check if a service is autostarted at boot time or not?

I did Google and IRC. I can not find the answer. Maybe there no such commands exist in Ubuntu. In the beginning, I thought all autostarted services would be under /etc/rc2.d/, but I was wrong about that. Some ones are configured only under /etc/init/*.conf. Then I tried the chkconfig tool (installed it manually), it does not work all the time. For instance, it gives the wrong result for mongodb which is autostarted from /etc/init/mongodb.conf.

service --status-all and initctl list can only tell the services' current status instead of autostart status. update-rc.d is a command to change the autostart status instead of showing the status.

If there is no answer to my question, I am just wondering why it's so hard to check autostart services in Ubuntu.

  • I think chkconfig --list will work right? on means that service is running on that runlevel, and that service will automatically start when the system boot. – max Nov 28 '12 at 13:07
  • 1
    As what I posted in my question, chkconfig does not always work. for example, it will give wrong result for mongodb. I think it might because mongodb uses /etc/init/mongodb.conf to do the autostart. – SSS Nov 29 '12 at 10:01
  • How about ls /etc/rc?.d ? – toxaq Jul 10 '13 at 12:30

Ubuntu uses Upstart instead of the traditional init system. Upstart is stronger than init, but it's a little bit more complicated than init.

Upstart, in contrast, is event based. An "event" can be something like "booting" ... or it can be a lot more specific, like "the network is ready to use now". You can specify which scripts depend on which events. Anything that isn't waiting for an event can run whenever there's CPU available.

This event-based system has another advantage: you can theoretically use it even after the system is up and running. Upstart is eventually slated to take over tasks such as or plugging in external devices like thumb drives (currently handled by udev and hal), or running programs at specific times (currently handled by cron).

As you should know now, a dead daemon (that doesn't run in startup) may be alive and starts because of an event.

Ubuntu have both /etc/init, for Upstart, and /etc/init.d, for the old SysV files. Some of the files in it are regular SysV Init scripts that haven't been migrated yet. But some services that have migrated maintain a link from /etc/init.d to /lib/init/upstart-job. If you run one of those, it works, but it prints a warning first:

Rather than invoking init scripts through /etc/init.d, use the service(8) utility, e.g. service mysql restart

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

On an Upstart machine, init comes from upstart. Instead of running a master rc script that calls the scripts for a specific runlevel, Upstart's init takes jobs from its job directory.

Now we know there's no simple way to list autostart daemons, you should list all daemons and check them one by one. The daemon may be started by init or by upstart or even by a later event. The simplest way to get this list is running this command in the shell:

initctl show-config

The output looks like this:

  start on startup
  start on ((startup and started udev) and not-container)
  start on (runlevel [23] and ((not-container or container CONTAINER=lxc) or container CONTAINER=lxc-libvirt))

Some items like the first one is so simple, hostname starts on startup. But other items may look more complicated. (But fortunately human readable :-) )

  • I knew most of what you posted. Even though there are something new which I don't know, they still can not solve my problem. I just would like to know if there is a command which can do the job easily (for both upstart and init services). It seems ubuntu does NOT have one. What a pity! by the way, "initctl" can only handle upstart services, rather than traditional init system. If there is no easy way, then I have to use the hard way... thanks. – SSS Nov 29 '12 at 11:03
  • I'd note, while not incorrect modern versions of ubuntu have moved out to systemd. Amusingly a good chunk of this answer is still valid – Journeyman Geek Sep 1 '17 at 14:50
  • 1
    new versions of Ubuntu do not use upstart but systemd unix.stackexchange.com/a/287282/147671 – João Pimentel Ferreira Jun 12 '19 at 20:40

Actually, all services are present under /etc/init.d only:

rc0.d contains the services which runs in runlevel 0
rc1.d contains the services which runs in runlevel 1
rc2.d contains the services which runs in runlevel 2
rc3.d contains the services which runs in runlevel 3
rc4.d contains the services which runs in runlevel 4
rc5.d contains the services which runs in runlevel 5
rc6.d contains the services which runs in runlevel 6

One more thing, all services are present under rc0.d rc1.d rc2.d rc3.d rc4.d rc5.d rc6.d also, but it is a symbolic link to /etc/init.d only.

See here this is the content of rc1.d directory:

lrwxrwxrwx 1 root root  20 Aug 17 14:54 K15pulseaudio -> ../init.d/pulseaudio
lrwxrwxrwx 1 root root  22 Nov 28 18:47 K20acpi-support -> ../init.d/acpi-support
lrwxrwxrwx 1 root root  20 Aug 17 14:54 K20kerneloops -> ../init.d/kerneloops
lrwxrwxrwx 1 root root  23 Nov  7 15:24 K20openbsd-inetd -> ../init.d/openbsd-inetd
lrwxrwxrwx 1 root root  15 Aug 17 14:54 K20saned -> ../init.d/saned
lrwxrwxrwx 1 root root  27 Aug 17 14:54 K20speech-dispatcher -> ../init.d/speech-dispatcher
-rw-r--r-- 1 root root 369 Apr 14  2012 README
lrwxrwxrwx 1 root root  19 Aug 17 14:54 S30killprocs -> ../init.d/killprocs
lrwxrwxrwx 1 root root  19 Aug 17 14:54 S70dns-clean -> ../init.d/dns-clean

Here you can observe the symbolic link to init.d (K15pulseaudio -> ../init.d/pulseaudio).

But here every service is linked to init.d, right? But every service will not start; the reason is two scripts.

The first one is an S script (S30killprocs)---> start

The second one is a k script (K15pulseaudio)---> kill

All the K script services kill the services and all S script services start the services for that runlevel.

In brief

S70dns-clean -> ../init.d/dns-clean start dns-clean service in runlevel 1.

K15pulseaudio -> ../init.d/pulseaudio kills pulseaudio service in runlevel 1.

  • Not true for upstart services, which may not appear here at all. – Wildcard Jul 2 '19 at 23:26

You can install sysv-rc-conf that is an ncurses program to configure/show the rc levels graphically.


Is there a command to show a list of all autostart services?

Look here: update-rc-d-cheat-sheet

Is there a command to check if a service is autostarted at boot time or not?

None, I know of (which does not mean anything ;), but you can start reading here: askubuntu forum - service dependency

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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