Home Systemd learning
Post
Cancel

Systemd learning

What is ‘Systemd’?

  • It’s an init system
  • The init system is the process running on your server(PID 1)
  • It manages all services that run in the background

Working with Units

  • Units in Systemd are resources that it’s able to manage.
  • These includes services, timers, mounts, automounts, and there’s more

Frequent commands

Start/Stop/Service

systemctl status <service-name> to check the status
systemctl start <service-name> to start the service
systemctl stop <service-name> to stop the service
systemctl restart <service-name> to restart the service

Enable/Disable

systemctl enable <service-name> to start the service while booting
systemctl disable <service-name> to not start the service while booting

enabled by default in ubuntu/Debian, disabled by defaults in Fedora/Centos

Where are unit files stored?

service files are text files that contain instructions on how systemd needs to manage the service.
Systemd Unit Directories

  1. /etc/systemd/system –
  2. /run/systemd/system – contains runtime systemd units
  3. /lib/systemd/system – anytime you install a library and it contains systemd service file, that’s stored here

If all three directories conains a same service file name, it takes priority as above order.
when need to override the config of the installed lib service, write a new service file in the higher priority unit directories. Because when updating the library via apt, the service file in lib will be overwritten.

This post is licensed under CC BY 4.0 by the author.