Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

The questions in short:
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 is 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 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.

Thanks.

share|improve this question
    
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
add comment

migrated from stackoverflow.com Nov 28 '12 at 12:35

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

4 Answers

Actully 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

First one is S script (S30killprocs)---> start

Second one is 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

share|improve this answer
add comment

Ubuntu uses Upstart instead of traditional init system. Upstart is stronger than init, but its a little bit 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 see list autostart daemons, you should list all daemons and check them one by one. the daemon may be start 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:

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

Some items like the first one in so simple, hostname starts on startup. But other items may be looks like more coplicated. (But fortunately human readable :-) )

share|improve this answer
    
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
add comment

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

share|improve this answer
add comment

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

hth Stefan

share|improve this answer
add comment

Your Answer

 
discard

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.