Init - jasper-zanjani/dotfiles GitHub Wiki

SystemVinit is a daemon process which was used by most distros until recently. Processes started serially and synchronously, wasting system resources; for years, a common hack was to run services in the background, simulating a sort of parallel processing. Upstart was developed by Canonical for Ubuntu, but abandoned in 2014.

SystemD was designed by a pair of Red Hat developers in 2010 to be a general purpose system manager. It was intended to address multiple shortcomings with sysvinit. It offers parallel execution, explicit dependencies between services, an escape from slow shell scripts, and per-daemon resource control and watchdogs.

SystemD introduces the concepts of [Units] which are subdivided into various unit types, each of which is associated with a filename extension. YouTube Linode

[Targets][target] (SystemD) Runlevels (System V Init)
poweroff.target 0
rescue.target 1
multi-user.target 3
graphical.target 5
reboot.target 6
emergency.target emergency

SystemD searches for units from most specific to most general.

  • /usr/lib/systemd/system default location where unit files are installed by packages
  • /run/systemd/system: Runtime configuration
  • /etc/systemd/system takes precedence over unit files located anywhere else

[SystemD][SystemD] components include:

  • [hostnamectl][hostnamectl]
  • [journalctl][journalctl]
  • [localectl][localectl]
  • [loginctl][loginctl]
  • [systemctl][systemctl]
  • [systemd-delta][systemd-delta]
  • [timedatectl][timedatectl]

Sysvinit chkconfig init runlevel service telinit

Upstart initctl

hostnamectl

Permanently change hostname to $HOSTNAME

hostnamectl set-hostname $HOSTNAME
journalctl

Show current disk usage of all journal files

journalctl --disk-usage

Continuously update the display as new log entries are created

journalctl -f

Display output in reverse (newest entries first)

journalctl -r
localectl

Change locale to French

localectl set-locale LANG=fr_FR.utf8
loginctl

Control the systemd login manager

systemctl

daemon-reload disable enable get-default isolate kill list-unit-files list-units mask reboot restart set-default start status stop suspend

Configure iptables to start on boot and start it immediately

systemctl enable --now iptables

Disable $SERVICE, ensuring it does not run on boot

systemctl disable $SERVICE

Change signal type sent to process to be killed

systemctl kill -s

Equivalent to chkconfig --list

systemctl list-unit-files --type=service

Prevent firewalld from being started inadvertently by another process

systemctl mask firewalld

Restart iptables.service

systemctl restart iptables

Configure system to boot to a GUI

systemctl set-default graphical.target

Start $SERVICE

systemctl start $SERVICE

Check status of $SERVICE

systemctl status $SERVICE
sudo systemctl is-active $SERVICE

Terminate $SERVICE

systemctl stop $SERVICE

Stop $SERVICE

systemctl stop $SERVICE

Suspend the system

systemctl suspend

Change target to runlevel emergency

systemctl isolate emergency.target
systemd-analyze
systemd-delta

Show files that are overridden with systemd
Display differences among files when they are overridden

systemd-delta --diff
timedatectl
chkconfig

Turn services on or off for runlevels Without arguments, chkconfig defaults to runlevels 3 or 5:

chkconfig

Display all services and runlevels

chkconfig --list

Turn {daemon} on for runlevels 3 and 5

chkconfig --level 35 daemon on

Turn {daemon} off

chkconfig daemon off
chkconfig NetworkManager off

Turn {daemon} service on

chkconfig daemon on
init

Access different runlevels

init 

Switch to runlevel {n}

init n
init 6 # reboot
runlevel

Show runlevel for system

runlevel 
service

Restart network service

service network restart

Check status of {daemon}

service daemon status

Stop {daemon}

service daemon stop
service mongodb stop
telinit

Refresh system after changes to /etc/inittab

telinit 

Cause operation to not send any notice to logged-on users

telinit--no-wall
initctl

Reload configuration files (on Upstart-controlled system)

initctl reload
⚠️ **GitHub.com Fallback** ⚠️