As much as I despise using the bourne shell as a general purpose programming language, the fact that the "init" scheme was based on a collection of shell scripts made it easy and simple to use the editor of your choice to manage the system.
The init program is the first actual process run by a linux system. It is responsible for launching every other process and becomes the ultimate parent of every process on the system.
The behavior of init is governed by the /etc/inittab file, which you ought to inspect, but perhaps not fiddle with. The one thing you could possibly want to fiddle with is the default runlevel, which is typically "5".
# The default runlevel. id:5:initdefault:You can type the "runlevel" command to see what the state of things is:
runlevel N 5
0 - halt the system 1 - single user 3 - multi user 5 - multi user with GUI 6 - reboot the systemOn the ebaz, 3 and 5 are identical. Both run the network. Level 1 (single user) does not run the network and requires a physical console to be in any way useful. I don't think I have ever seen a system where 2 or 4 were used.
There is a program "telinit" that is used to send a message to the init process telling it to change to a different runlevel. Typing "telinit 0" would halt the system (as an example).
drwxr-xr-x 2 root root 0 Apr 21 2017 rc0.d drwxr-xr-x 2 root root 0 Apr 21 2017 rc1.d drwxr-xr-x 2 root root 0 Apr 21 2017 rc2.d drwxr-xr-x 2 root root 0 Apr 21 2017 rc3.d drwxr-xr-x 2 root root 0 Apr 21 2017 rc4.d drwxr-xr-x 2 root root 0 Apr 21 2017 rc5.d drwxr-xr-x 2 root root 0 Apr 21 2017 rc6.d drwxr-xr-x 2 root root 0 Jan 1 1970 rcS.dClose eyes will have noticed the last directory has an "S" rather than a "5". The "S" stands for startup.
These directories contain shell scripts. As an example, here is what the contents of rcS.d looks like (the startup directory):
-rwxr--r-- 1 root root 200 Jun 29 2017 K95cgminer.sh lrwxrwxrwx 1 root root 19 Apr 21 2017 S02banner.sh -> ../init.d/banner.sh lrwxrwxrwx 1 root root 18 Apr 21 2017 S02sysfs.sh -> ../init.d/sysfs.sh -rwxr--r-- 1 root root 858 Jun 29 2017 S03mountall.sh lrwxrwxrwx 1 root root 14 Apr 21 2017 S04mdev -> ../init.d/mdev lrwxrwxrwx 1 root root 21 Apr 21 2017 S05modutils.sh -> ../init.d/modutils.sh lrwxrwxrwx 1 root root 22 Apr 21 2017 S06alignment.sh -> ../init.d/alignment.sh lrwxrwxrwx 1 root root 22 Apr 21 2017 S06checkroot.sh -> ../init.d/checkroot.sh lrwxrwxrwx 1 root root 18 Apr 21 2017 S07bootlogd -> ../init.d/bootlogd lrwxrwxrwx 1 root root 34 Apr 21 2017 S29read-only-rootfs-hook.sh -> ../init.d/read-only-rootfs-hook.sh lrwxrwxrwx 1 root root 30 Apr 21 2017 S37populate-volatile.sh -> ../init.d/populate-volatile.sh lrwxrwxrwx 1 root root 19 Apr 21 2017 S38devpts.sh -> ../init.d/devpts.sh lrwxrwxrwx 1 root root 18 Apr 21 2017 S38dmesg.sh -> ../init.d/dmesg.sh lrwxrwxrwx 1 root root 17 Apr 21 2017 S38urandom -> ../init.d/urandom lrwxrwxrwx 1 root root 21 Apr 21 2017 S39hostname.sh -> ../init.d/hostname.sh lrwxrwxrwx 1 root root 21 Apr 21 2017 S55bootmisc.sh -> ../init.d/bootmisc.sh lrwxrwxrwx 1 root root 23 Apr 21 2017 S65inetd.busybox -> ../init.d/inetd.busyboxScripts that begin with "S" are run when the level is entered, and the "K" (kill) scripts get run when the level is exited. They are run in the order given by the next digits. So S02 runs before S38 and so on.
Note that these are generally links to actual files in the init.d directory. This is just to save space and centralize things since many scripts are duplicated in most or all of the rc directories.
This gives you the general idea. Details of the scripts themselves is something that I don't intend to tackle here.
Tom's Computer Info / [email protected]