SysV startup sequence
OS startup sequence (SysV) | Debian | Red Hat |
At startup /sbin/init executes all instructions on /etc/inittab . This script at first switches to the default runlevel… | id:2:initdefault: | id:5:initdefault: |
… then it runs the following script (same for all runlevels) which configures peripheral hardware, applies kernel parameters, sets hostname, and provides disks initialization… | /etc/init.d/rcS | /etc/rc.d/rc.sysinit or/etc/rc.sysinit |
… and then, for runlevel N, it calls the script/etc/init.d/rc N (i.e. with the runlevel number as parameter) which launches all services and daemons specified in the following startup directories: | /etc/rcN.d/ | /etc/rc.d/rcN.d/ |
The startup directories contain symlinks to the init scripts in /etc/init.d/ which are executed in numerical order. Links starting with K are called with argument stop, links starting with S are called with argument start.
lrwxrwxrwx. 1 root root 14 Feb 11 22:32 K88sssd -> ../init.d/sssd lrwxrwxrwx. 1 root root 15 Nov 28 14:50 K89rdisc -> ../init.d/rdisc lrwxrwxrwx. 1 root root 17 Nov 28 15:01 S01sysstat -> ../init.d/sysstat lrwxrwxrwx. 1 root root 18 Nov 28 14:54 S05cgconfig -> ../init.d/cgconfig lrwxrwxrwx. 1 root root 16 Nov 28 14:52 S07iscsid -> ../init.d/iscsid lrwxrwxrwx. 1 root root 18 Nov 28 14:42 S08iptables -> ../init.d/iptables
The last script to be run is S99local -> ../init.d/rc.local ; therefore, an easy way to run a specific program on boot is to add it to this script file.
/etc/init.d/boot.local runs only at boot time, not when switching runlevel.
/etc/init.d/before.local (SUSE) runs only at boot time, before the scripts in the startup directories.
/etc/init.d/after.local (SUSE) runs only at boot time, after the scripts in the startup directories.
Debian | Red Hat | |
To add or remove services at boot sequence: | update-rc.d service defaults update-rc.d -f service remove | chkconfig –add service chkconfig –del service |
Parameters supported by the init scripts | ||
start | Start the service | Mandatory |
stop | Stop the service | |
restart | Restart the service (stop, then start) | |
status | Display daemon PID and execution status | |
force-reload | Reload configuration if the service supports this option, otherwise restart the service | |
condrestart try-restart | Restart the service only if already running | Optional |
reload | Reload service configuration |
/etc/init.d/service start
service service start (Red Hat) Start a service
rcservice start (SUSE)