Systemd is the new system and service manager for Linux. It is a replacement for init system and can manage system startup and services. It starts up and supervises the entire system.
List all running services
Start/stop or enable/disable services
Activates a service immediately:
# systemctl start foo.service
Deactivates a service immediately:
# systemctl stop foo.service
Restarts a service:
# systemctl restart foo.service
Shows status of a service including whether it is running or not:
# systemctl status foo.service
Enables a service to be started on bootup:
# systemctl enable foo.service
Disables a service to not start during bootup:
# systemctl disable foo.service
Check whether a service is already enabled or not:
# systemctl is-enabled foo.service; echo $?
0 indicates that it is enabled. 1 indicates that it is disabled
How do I change the runlevel?
systemd has the concept of targets which is a more flexible replacement for runlevels in sysvinit.
Run level 3 is emulated by multi-user.target. Run level 5 is emulated by graphical.target. runlevel3.target is a symbolic link to multi-user.target and runlevel5.target is a symbolic link to graphical.target.
You can switch to ‘runlevel 3′ by running
# systemctl isolate multi-user.target (or) systemctl isolate runlevel3.target
You can switch to ‘runlevel 5′ by running
# systemctl isolate graphical.target (or) systemctl isolate runlevel5.target
How do I change the default runlevel?
systemd uses symlinks to point to the default runlevel. You have to delete the existing symlink first before creating a new one.
# rm /etc/systemd/system/default.target
Switch to runlevel 3 by default
# ln -sf /lib/systemd/system/multi-user.target /etc/systemd/system/default.target
Switch to runlevel 5 by default
# ln -sf /lib/systemd/system/graphical.target /etc/systemd/system/default.target
systemd does not use /etc/inittab file.
List the current run level
runlevel command still works with systemd. You can continue using that however runlevels is a legacy concept in systemd and is emulated via ‘targets’ and multiple targets can be active at the same time. So the equivalent in systemd terms is
# systemctl list-units --type=target
Powering off the machine
You can use
Some more possibilities are:
shutdown -P now
halt used to work the same as
poweroff in previous Fedora releases, but systemd distinguishes between the two, so
halt without parameters now does exactly what it says – it merely stops the system without turning it off.
Service vs. systemd
# service NetworkManager stop
# systemctl stop NetworkManager.service
Chkconfig vs. systemd
# chkconfig NetworkManager off
# systemctl disable NetworkManager.service
systemd has a built-in readahead implementation. It should improve bootup speed but your mileage may vary depending on your hardware. To enable it:
# systemctl enable systemd-readahead-collect.service # systemctl enable systemd-readahead-replay.service
List the services that can be started or stopped
ls /lib/systemd/system/*.service /etc/systemd/system/*.service
Check whether a service is configured to start or not in the current environment
systemctl is-enabled foobar.service
List what levels this service is configured on or off
To reload the configuration of service (say ssh), without restarting it
systemctl reload sshd