When you boot Linux up (push the power button on your computer), BIOS (or UEFI) kicks in and then it finds the OS on the hard drive. It reaches out to the hard drive and finds the bootloader. The bootloader tells where the kernel is, and kernel starts Linux.
Earlier we used to have SysV.
systemd is an init system and system manager. It's a one monolithic program that takes the control of the whole modern initialization process. It takes care of attaching hardware, mapping network drive, firing up services, and controlling that access.
To interact with
systemd, we use
systemctl. This is the main command for this.
sudo systemctl --type=service
sudo systemctl --type=service --state=running
systemctl, for most service management commands, you can actually leave off the
.service suffix, as
systemd is smart enough to know that you probably want to operate on a service when using service management commands.
sudo systemctl start application.service # start servicesudo systemctl start application # start servicesudo systemctl stop application.service # stop servicesudo systemctl restart application.service # restart servicesudo systemctl reload application.service # reload servicesudo systemctl status sshd.service # service status
To start a service at boot, use the
sudo systemctl enable application.service # enable a service at bootsudo systemctl disable application.service # disable a service at boot
systemd-analyze is a command that lets you analyze how long it took your system boot from the time systemd (when kernel invokes systemd) kicks in.
There are two types of run-levels now:
graphical.target (graphical and multi-user mode)
multi-user.target (non-graphical or text-only mode but multi-user)
And, any of them could be set to run either on boot (persistently) or temporarily.
In the below example, I changed from graphical to multi-user (text-only interface) but it doesn't take effect immediately until you boot the system.
If you want to do into the text-only mode without booting the system, you can use this command.
sudo systemctl isolate multi-user.target
Imagine your system got hacked and you want to isolate everyone and enable a single user mode so that you can do the forensics and look into the loopholes. You can go into the rescue mode (i.e. the single user mode in systemd):
sudo systemctl rescue