What is Sysvinit?
This is a package, containing a group of processes that are responsible for controlling the basic functions of the system
Primarily, it includes the ‘init’ application (located in
/sbin/init), which is the very first application started by the kernel after the boot loader starts the boot process.
The init program then controls the startup , running and shutdown of all other programs (it becomes the ‘parent’ of everything running on the system)
Boot Process
Sysvinit Runlevels
0-HALT(shutdown)
1-single user
2-Multiuser(no network or remote filesystem)
3-full multi user(including network and remote filesystem)
4-unused
5-x11(full multiuser with Graphical desktop environment)
6-Reboot
/etc/inittab
Defines run levels and default run level of the system, is scanned by init during boot to determine what scripts are executed, according to run level.
systemd
This is an initialization system for bootstrapping the user space and managing all processes subsequent to system start.
It was developed to replace the “sysvinit” init system and address some of the shortcomings of it. Currently,systemd is the default initialization and service management process of almost all modern Linux distributions.
Systemd is generally considered to be more efficient,allows parallel operations,has fewer dependencies,allows for service prioritization and precedence,and reduces start up time.
Systemd boot process
systemd runlevels
0- poweroff.target or shut down
1- rescue.target (Single User/Rescue Shell)
2-multi-user.target ( Non-graphical, Full Network, Multi-User)
3-multi-user.target ( Non-graphical, Full Network, Multi-User)
4-multi-user.target ( Non-graphical, Full Network, Multi-User)
5- graphical.target (Graphical Desktop, Multi-User)
6-reboot.target (Reboot)
Where are the location of systemd targets?
/usr/lib/systemd/system
upstart
Where is the init scripts in Red hat located?
in the /etc/init.d/rc(RunLevelNumber).d
or
/etc/rc(RunLevelNumber).d
What is the difference between S scripts and K scripts?
The K scripts are kill scripts used to stop any processes that should not be running at given run level.
The S scripts are start up scripts used to start any processes that should be running at given run level.
if you boot into run level3, what directory would scripts be run from? How does system decide which scripts will be run first?
scipts will be run from /etc/rc.d/rc3.d
The scripts are numbered and are executed in that order. Kill scripts are always run before startup scripts.
what is the last script that would be execute at any runlevel?
/rc.local
Given that the scripts in /etc/rc.d/rc#.d are symbolic links to the actual start up scripts, where can these actually be found?
/etc/init.d
how does systemd determine the default run level?
using /usr/lib/systemd/system/default.target
what is key-value pair?
It is a description often seen in the systemd target files, where it is equalled to other targets. Ex. Requires=multi-user.target
The keys are fairly easy to understand:
- The “Description” is a basic description of the
target,
- “Documentation” provides information on how to receive more information,
- “Requires” defines which targets or units must run before using this target, while
- “Wants” lists which targets or services to run after the required services,
- “Conflicts” notes what services cannot be running for the target to work,
- “After” shows which targets and services can run after the runlevel 5 services have started,
- and “AllowIsolate” denotes whether or not a system can be used with the systemctl isolate command.
Target units
units replace the concept of initv scripts for services. service files are configured to execute scripts that are responsible to starting ssh as example.
command to display current runlevel
runlevel
A terminal command that gives the current and previous run levels of a sysvinit system and a systemd system. The letter N in the previous run level section means the previous run level information is not available or there was no previous run level.
To change runlevel
init [#]
or
telinit [#]
changing to 5 or 6 or 0
5 will kill the GUI (xwindows)
shutdown
A terminal command used to shutdown, restart,set a time to shutdown or restart, cancel a shutdown or restart and/or send admin messages on the state of a shutdown command.
Flags:
shutdown -r : Reboots the system imminently
shutdown -h: Powers down the system to the last process, then ask the user to power off.
shutdown -P: Will power a system all the way down as log as ACPI (Advanced Power Management) is available.
shutdown -r 30 &
This command will shutdown the system in 30 minutes and will broadcast a message to all attached users using wall. Since we used the “&” flag the command was issued as a backrounb job and the console will return for use after the command is issued.
To fake a shutdown message and send it to all users using wall (The system does not actually shut down)
shutdown -k “message”
To cancel a planned shutdown process
shutdown -c
halt command
halt -f: it force to halt the system to the last process, then ask the user to power off.
halt -p: Will power a system all the way down