The init process,
/sbin/init is not a shell script and it doesn't exit (under normal conditions).
In Unix-based computer operating systems, init (short for initialization) is the first process started during booting of the computer system. Init is a daemon process that continues running until the system is shut down.
It is the direct or indirect ancestor of all other processes and automatically adopts all orphaned processes.
It is the first user space process the kernel fork and exec's after the kernel has initialised itself. Thats why its called
PID1 (process id 1).
There are different implementations nowadays of the init process, e.g. upstart or systemd, with the original implementations being based on systemV init.
What they all basically do is - on boot - read configuration files for each process that is a candidate to be launched. Traditionally these config files are located in
/etc/init/. If the process is flagged for launch then the process is started or - if its config says "don't start me on boot" then its not started, but may still be started manually later.
If the process is flagged for launch the way - traditionally - that they would have been started is that the init system would execute a shell script corresponding to the daemon in
Some of the differences between newer init systems and the original system V init is that system V uses numeric run levels, 0,1,2, etc to determine system state and systemd or upstart use named identifiers like
Also - I believe - newer init systems launch daemons themselves and use their own so called "unit" files to define config directives rather than invoke a shell script.
e.g for nginx there is a config file
/lib/systemd/system/nginx.service which defines startup directives like:
Description=A high performance web server and a reverse proxy server
ExecStartPre=/usr/sbin/nginx -t -q -g 'daemon on; master_process on;'
ExecStart=/usr/sbin/nginx -g 'daemon on; master_process on;'
ExecReload=/usr/sbin/nginx -g 'daemon on; master_process on;' -s reload
ExecStop=-/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/nginx.pid
You would enable it with a command like
sudo systemctl enable nginx.service this will create a symlink in
pointing to the unit file in:
sudo systemctl disable nginx.service would remove the symlink and the service won't be launched on startup.
Newer init systems are backward compatible with systemV init scripts and will read configs in
/etc/init and launch shell scripts in