I tried to display the list of startup scripts for the current runlevel at bootup. I wrote the following code. rl=`runlevel | cut -d   -f2`ls /etc/rc.d/rc$rl.d/S* | cut -d / -f5sleep 10It's working if I put this code in rc.local file.But it's not working if I put it in rc file or in a separate script file abc in /etc/init.d and by creating softlinks in runlevel directories.But simple commands like follows are able to run in all the methods.ls /etc/init.dDo some commands like runlevel or piping won't work unless some of the scripts have started? Or is there something else?And if I put my code in rc file, my code runs before and after reboot. So what's the difference between rc, rc.local and rc.sysinit files?Where exactly I need to edit those files?Also I can find S99local -> softlink for rc.local in 2, 3, 4 and 5 runlevels.Does it mean that rc.local won't run on runlevel 1?
What is the difference between rc, rc.local and rc.sysinit?
init script;init.d;sysvinit;rc
rc  is typically not used by linux distributions but is used in BSDrc.local is used to be able to execute additional commands during the startup without having to add symlinks.rc.sysinit seems to be redhat specific and is executed very early in the process. It is executed as one of the first scripts while rc.local is executed later.Also I can find S99local -> softlink for rc.local in 2,3,4 and 5 runlevels. Does it mean that rc.local wont run on runlevel 1?Correct, that means that S99local which is  a symlink to /etc/rc.local will be one of the last scripts executed when entering runlevels 2, 3, 4 and 5. It won't get executed for runlevel 1 as 1 is the single user runlevel, typically used for rescue/maintenance work.