Sunday, October 9, 2016

systemd and its "unit"

When the system is started, a unit called default.target is activated at first. The setting file for this unit is at a directory: /etc/systemd/system.

graphical.target is a unit which corresponds to runlevel 5. Although runlevel was used in SysVinit, units called target are used in systemd.

runlevel : target
0 : poweroff.target
1 : rescue.target
2, 3, 4 : multi-user.target
5 : graphical.target
6 : reboot.target

To manage services in systemd, "systemctl" command is used.

# systemctl [subcommand] [unit name] [-t unit type]

The followings are main sub command:
start: this starts a service.
stop: this stops a service.
restart: this restarts a service.
reload: reload (re-check) the setting of a service.
status: this is used to check the status of a service.
is-active: this checks if the service is active.
enable: when this is used to a service, the service is started automatically when the whole system starts.
disable: when this is used to a service, the service is NOT started automatically when the whole system starts.
list-unit-files: displays all units.
reboot: reboot the system.
poweroff: power off the system.