What are the s and k scripts in the etc rcx.d directories?

To understand this you need to have a brief knowledge on the booting procedure of Linux machine.
Running all the scripts under /etc/rc.d is the last step of successful booting a Linux OS.
As per the 5th step /etc/inittab file is executed which tells the OS to boot into a particular level as defined in the config file.

# Default runlevel. The runlevels used by RHS are:
#   0 - halt (Do NOT set initdefault to this)
#   1 - Single user mode
#   2 - Multiuser, without NFS (The same as 3, if you do not have networking)
#   3 - Full multiuser mode
#   4 - unused
#   5 - X11
#   6 - reboot (Do NOT set initdefault to this)
#
id:3:initdefault:

As you can see above my Linux machine will boot into runlevel 3. So in the next and last step the OS will execute all the scripts stored under /etc/rc3.d where rc3.d is used for runlevel 3.
Similarly you will find one directory for each runlevel from rc0.d till rc6.d
All these directories contains executable scripts which has to be start at boot up of Linux OS.
If you look inside this directory, you will find scripts like as shown below

lrwxrwxrwx 1 root root 16 Feb 16  2010 K10psacct -> ../init.d/psacct
lrwxrwxrwx 1 root root 15 Sep 10  2010 K15httpd -> ../init.d/httpd
lrwxrwxrwx 1 root root 13 Sep 10  2010 K20nfs -> ../init.d/nfs
lrwxrwxrwx 1 root root 14 Feb 16  2010 K25sshd -> ../init.d/sshd
lrwxrwxrwx 1 root root 17 Feb 16  2010 K30postfix -> ../init.d/postfix
lrwxrwxrwx 1 root root 19 Oct 12  2010 S20eventlogd -> ../init.d/eventlogd
lrwxrwxrwx 1 root root 16 Jan 28  2013 S21lsassd -> ../init.d/lsassd
lrwxrwxrwx 1 root root 20 Sep 10  2010 S22messagebus -> ../init.d/messagebus

As you see all the scripts are nothing but a softlink pointing to their original scripts in some other directory.
All the scripts are either starting with S or K, now what does this means?
Here S means start and K means Kill
The numerical value specifies the order in which the script will be executed.
For example 
S20eventlogd will be executed before S21lsassd when the OS boots similarly K10psacct will be executed before K15httpd when the system starts to shut down.
 
Why symlinks are used rather than putting the script inside these directories?
Because of the following two reasons

  1. You will have to put the same script in each runlevel directory of rcx.d
  2. Even though you are will to do step 1, you won't be able to define the order as per which the script will be executed during startup and shutdown.
IMPORTANT NOTE:

This is one good interview question when you might be asked the default location of all the rcx.d scripts?
Ans: /etc/rc.d/init.d or /etc/init.d as init.d inside /etc is just a symlink of /etc/init.d/rc.d

 
Related Articles
How to get a list of open ports in Linux?
How to check all the currently running services in Linux
How to auto start service after reboot in Linux