linux_wiki:init_systems

This is an old revision of the document!


Init Systems

General Information

Down and dirty quick info about three different init systems that Linux uses; SysV init, upstart, and systemd.

Checklist

  • Distro: Varies, depending upon init system.

Distributions: RHEL/CentOS ⇐ 6 (RHEL 6 uses an init/upstart combination), Debian ⇐ 7

  • 0 : shutdown
  • 1 and S : single user mode
  • 2 - 5 : include networking support (GUI login can start at one of these, distro depending)
  • 6 : reboot level
  • Set in file: /etc/inittab

Example with run level 5 as default:

id:5:initdefault

/etc/init.d/

The rc#.d directories contain symbolic links to the scripts in /etc/init.d.

# = the run level, ie rc0.d, rc1.d, rc2.d, rc3.d, rc4.d, rc5.d, rc6.d

Locations

  • /etc/rc.d/rc#.d or
  • /etc/rc#.d

Script Names

  • Scripts are named for if they are going to Start(S) or Kill(K) the script, a sequence number, and then the name of the script.
  • /etc/rc2.d/S80cups = This would Start(S) cups after any scripts numbered S01 to S79
  • /etc/rc0.d/K80cups = This would Stop/Kill (K) cups after any scripts numbered K01 to K79
  • chkconfig: Red Hat based systems
  • update-rc.d: Debian/Ubuntu

List all services and the run levels they will start on:

chkconfig --list

List a single service:

chkconfig --list httpd

Set a service to start on boot

chkconfig httpd on

Show service status

service httpd status
or
/etc/init.d/httpd status

Stop/start/restart a service

service httpd stop
service httpd start
service httpd restart

Distributions: Ubuntu 9.10 - Current (migrating to systemd), RHEL/CentOS 6 (some scripts)

Upstart uses event driven jobs, instead of run levels to executes scripts. It does have events for rc0-6 to maintain comptability with init.

  • Location: /etc/event.d/

List all known jobs

initctl list

Show status of a job

initctl status httpd

Stop/start/restart a job

initctl stop httpd
initctl start httpd
initctl restart httpd

Distributions: RHEL/CentOS 7, Debian 8, Ubuntu 15.4?

All of systemd unit scripts are located here (and sub folders):

/usr/lib/systemd/

Systemd uses this directory of symlinks to run those scripts:

/etc/systemd/system/

Other systemd configuration:

/etc/systemd/

List all loaded units

systemctl list-units
or
systemctl

List all loaded but inactive too

systemctl --all

List all installed units

systemctl list-unit-files

Show status of a unit

systemctl status NetworkManager.service
or
systemctl status NetworkManager

Stop/start/restart a unit

systemctl stop NetworkManager
systemctl start NetworkManager
systemctl restart NetworkManager

On systemd based systems, the laptop suspend on lid closed can be disabled by changing the logind config.

1) Edit /etc/systemd/logind.conf

2) Uncomment “HandleLidSwitch” and set to ignore

HandleLidSwitch=ignore
  • linux_wiki/init_systems.1426039460.txt.gz
  • Last modified: 2019/05/25 23:50
  • (external edit)