On 30 Nov 2024 20:33 +0800, from bit...@secubox.org (Bitfox):
> May I ask what's the main difference between systemd and sysv for init
> system?

I think it's fair to say that systemd does a great deal more, as well
as that it brings things into the init system which have traditionally
been done by separate pieces of software.

SysV init is primarily a way to manage automated start and stop of
services at runlevel changes, by executing a series of programs placed
in magic directories (/etc/rc?.d) with specific parameters; and does
very little else. Things like recovering from service failures,
dependency management, etc. are up to those scripts (or the system
administrator).

Whereas systemd aims to be more of a system _management_ tool;
bringing in system log storage, time synchronization, file system and
service dependency management, on-demand service startup, network
management, and a great deal more.

A lot of people have very strong opinions about this.

_From a user perspective_, there's actually not all that much
difference: to get to a usable, running system, both systemd and
sysvinit must accomplish roughly the same things and start the same
services; and to interrogate the state of the running system, the
administrator must do roughly the same things. The difference here is
in _how_ this is accomplished and exactly which software is used for
each part of it. Compatibility shims have also existed for a long
time, and nothing really prevents for example a distribution from
packaging /etc/init.d/* scripts which are wrappers around the
corresponding systemctl commands on a systemd system.

For example, whereas on a more traditional sysvinit system using
traditional text-based log files, you might use something like

# awk '{ if($5 ~ "^postfix[[]") { print } }' </var/log/messages

on a systemd system you'd use, to roughly the same effect

# journalctl --no-pager --all -u postfix

(where -u xx can alternatively be written --unit=xx)

and to restart a service, instead of SysV init's

# /etc/init.d/postfix restart

one might do

# systemctl restart postfix

-- 
Michael Kjörling
🔗 https://michael.kjorling.se

Reply via email to