I have come across cases where I want to run something at start up of a machine and I has to use commands like
I would use one or the other command and used to get things to work at the end without actually knowing what they meant and why it’s service
sometimes and systemctl
for the rest.
What is init?
- Init is the first process that is executed by the Linux kernel and it is the responisibility of the init process to spawn all other processes.
- The
init
process is given a PID of 1. init
becomes the parent of all the other processes that are spawned from it.- Is the init process couldn’t be started for some reason the machine goes into a stage called
Kernel Panic
. - All the system services and daemons are started by the init process.
init.d
- init.d (also called System V init) is once such init daemon process that takes the responsibility of spawning the required system processes and daemons.
- init.d does everything synchronously, that is the next task is picked up only when the current process has finished executing, or timeout.
- The synchronous nature of init resulted in slower boot times.
- The
service
command is used to run System V init scripts.
systemd
- systemd which is another init daemon is created to overcome the short comings of init.
- Major linux distributions have adopted systemd real quick.
- It spawns processes parallely reducing the boot time.
systemctl
command is used by systemd.