Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

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

Why do scripts beginning with an 'S' exist in /etc/rc.d/rc{0,6}.d? Will there be trouble if I change the 'S' to a 'K'?

Is the behavior of the system changed when it halts/reboots?

share|improve this question

Yes, the traditional system V init style (what that is) makes symlinks that start with S, or K. those with S means "start", and they are run with the "start" parameter when that runlevel is entered. Those with K means "kill", those services are run with the "stop" parameter when that runlevel is entered. This makes the different run levels have different sets of services running. If you cange one from S to K the server won't be started, it will be stopped then. That may or may not be a problem depending on whether or not it was a critical service.

BTW, this method is being obsoleted by newer, dependency based startup systems in newer Linux distros.

share|improve this answer
I mean changing a link in rc0.d or rc6.d, will this change the behavior of the system? – TheoYou Jul 10 '11 at 12:29
Why don't you elaborate on your original question so we don't have to guess what you really mean? Thanks. – Keith Jul 10 '11 at 12:33
I think in both of those it doesn't make sense to have any "S" scripts since 0 is shutdown and 6 is reboot. Runlevels 0 and 6 aren't normally "exited from." If you want to disable a script from running on shutdown or reboot the right thing to do is remove the symlink. If you want to change the order it executes, you want to "rename" the symlink to modify the two digit number, i.e. change K10whatever to K20whatever. You should consult the script itself to know what it actually does. – LawrenceC Jul 10 '11 at 14:01
This is a really bad answer. The OP was specifically asking about the implication of having a start script in the shutdown/restart directory. – aaa90210 Jul 9 '13 at 0:01
@aaa90210 No, he wasn't. – Keith Jul 10 '13 at 0:19

The best answer I found to this on another website is that the K and the S are ignored on run levels 0 and 6 as the system will simply executed all of those scripts with the stop command in alpha-numeric order anyway... So S or K doesn't even matter.

I can prove this in a default install of Ubuntu where I have examples like the following:

K20restsrv K20zfs-mount K20zfs-share S40umountfs S60umountroot S90halt

The K examples have stop commands within those scripts. The scripts also specify default run levels when the start and stop commands will run like it shows default start on run levels 2,3,4,5 and default stop on 0,1,6

share|improve this answer
Yes the K and S are ignored. On my old system, the order of execution would be changed. K first, then S. I had my own answer then, but in the wrong place. You can check out the revision history. Anyway, it doesn't matter now, since we have systemd. – TheoYou Aug 30 '14 at 12:30
Huh! "alpha-numeric order"! K comes before S anyway. – TheoYou Aug 30 '14 at 12:33

You must log in to answer this question.

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