3.4 Init Scripts Flashcards
What is the role and function of init scripts?
Init scripts determine which services and daemons are configured at various runlevels.
Which distribution stores the init scripts in the /etc/rc.d/init.d directory?
System V distributions store the init scripts in the /etc/rc.d/init.d directory.
What does the /etc/init.d/rc5.d directory contain?
The /etc/init.d/rc5.d directory contains init scripts for services configured for runlevel 5.
How would you view what init scripts are available in your distribution?
You can view the init scripts available by examining the /etc/rc.d/init.d directory (System V distributions) or the /etc/init.d directory (BSD distributions).
What command runs an init script?
The service command runs an init script.
What identifier kills or starts an init script?
The ‘K’ identifier kills an init script, while the ‘S’ identifier starts an init script.
What is involved in init script configuration?
Specifying whether specific daemons start at a specified runlevel.
Where are init scripts stored?
Init scripts are stored in /etc/init.d (BSD distribution) or /etc/rc.d/init.d (System V distribution).
What are some features of init scripts?
- They are configured differently for BSD and System V distributions.
- They have symbolic links that are stored in subdirectories that correspond to the runlevel under which each script should start.
- They can be started and stopped manually.
- They are started at boot using the init script.
- They contain code that determines the appropriate runlevels on which the script can operate.
- Configuration commands use code in the scripts to configure the appropriate levels at which scripts can start and stop.
What is the code inside an init script that determines appropriate runleves on which the script can operate?
- The default-start line defines the runlevels in which the script starts by default.
- The required-start line defines services that must be running before this service can start.
- The should-start line defines the services that are recommended to start before this service starts.
What does the rc script do?
The rc script (BSD and System V) switches between runlevels.
What does the halt script do?
The halt script (BSD and System V) stops and reboots the computer. It runs when the init 0 or init 6 commands are invoked.
What does the boot script do?
The boot script (BSD) is run by the init process when a computer starts. It runs the scripts contained in /etc/init.d/boot.d and performs tasks that include:
- Loading the kernel module
- Checking the file system
- Setting the system clock
What does the rc.sysinit script do?
The rc.sysinit script (System V) is run by the init process when a computer starts. This script performs tasks that include:
- Loading the kernel module
- Checking the file system
- Setting the system clock
What does the boot.local script do?
The boot.local script (BSD) runs specific tasks at startup as specified by the administrator. It is where you put commands you want to run every tim ethe system starts.
What does the rc.local script do?
The rc.local script (System V) runs specific tasks at startup as specified by the administrator. It is where you put commands you want to run every tim ethe system starts.
How does init determine the default runlevel at boot time?
At boot time, init uses the /etc/inittab file to determine the default runlevel, such as runlevel 5.
Given a specified runlevel, how does init know which processes to start?
The init process looks at the directory associated with the runlevel to determine what processes to start. The directory for runlevel 5 is named rc5.d. Additional directories named rc0.d through rc6.d specify what processes to start for each runlevel.
What kinds of files do the rc directories contain?
Each rc directory contains symbolic links that point to a specific init script in /etc/init.d or /etc/rc.d/init.d. Init follows the links and runs the scripts to start or stop processes. Init repeats the process using the appropriate rc directory whenever the runlevel changes.
What do the names of the symbolic links in the rc directories mean?
- Link names starting with an S start a script for the runlevel.
- Link names starting with a K kill a running process when the computer changes runlevels.
What does the service command do?
Manages the current state of a daemon.
What are the options of the service daemon_name command?
- start starts a daemon that is not currently running.
- stop halts a running daemon.
- restart stops and restarts a daemon.
- reload requests that a daemon read and apply its configuration files without stopping.
- status shows the status of a single daemon or daemons.
- –status-all shows the status of all daemons.
Aside from the service command, how else can you control a daemon init script?
You can use the absolute path to the daemon script and the option to configure the daemon (e.g., /etc/rc.d/init.d/httpd stop).
What does the insserv command do?
It configures default runlevels for a daemon on a BSD distribution.
How does the insserv command determine the default runlevels for a daemon and dependent daemons?
It references the INIT INFO script section of each daemon to determine the default runlevels for the daemon and dependent daemons.
What does the command insserv script_name do?
Starts the script and associated daemon at the runlevels specified in the init block of the script code.
What does the command insserv -r script_name do?
Keeps the script and associated daemon from starting at any runlevel.
What does the command insserv -d script_name do?
Restores the script and associated daemon to default runlevels defined in the init block of the script code.