systemd
What is systemd?
Lennart Poettering and Kay Sievers wrote systemd. The first release was in 2010. Many Linux distributions start it at boot. Ubuntu is one of them. Each service has a unit file. The ending seen most is .service. systemctl start opens the service now. systemctl enable ties it to the next boot. These two are not the same. journalctl shows the log. The kernel talks to the hardware. systemd keeps the order of services after the kernel has started. Some systems, such as Alpine, do not use it.
What is systemd used for?
systemd is for a site, a database, and a background program to stay open.
- Starting the web server at boot
- Raising a fallen service again
- Reading the last error in the log
- Opening one service after another
What can you do with systemd?
With systemd you open and close a service, tie it to boot, and read the log. It does not write the program's code. When the path or the user is wrong, the service falls. Starting without enable opens it only now. When the machine turns off, that service does not come back by itself.
Is systemd hard to learn?
One start command is easy. The difficulty is the path in the unit file. If the program's full path is not written, systemd cannot find it. The working folder may not be your terminal folder. When restart is set wrong, a fallen program opens again without a pause and fills the log. If Alpine has no systemctl, the command belongs to another tool.
Advantages and limits
Advantage: the boot order is in one place, a fallen service can be raised, and the log is read separately. Limit: it is not on every Linux, and a unit mistake keeps the service quiet. systemd is not the kernel and it is not cron.
Basic ideas
A unit is the service's file. start opens it now. enable writes it to the next boot.
- systemctl status shows the state
- journalctl reads the log
- .service is the unit seen most
- The kernel starts before systemd
A short example
This command shows whether a service is open now. It does not create it.
systemctl status nginx
Common questions
- Are systemd and the Linux kernel the same? No. The kernel talks to the hardware. systemd keeps the order of services.
- Are systemd and cron the same? No. cron calls a command when the time comes. systemd keeps a service open.
- Are start and enable the same? No. start opens it now. enable ties it to the next boot.