Linux systemctl: Check and Manage Services
systemctl is a command to check the status of services and other units managed by systemd, start or stop them, and set whether they are enabled at boot. The current running status and the enabled status at boot are different, so each must be checked separately.
Before Starting
systemd is the system and service manager for Linux, and the units it manages include not only services (.service) but also timers and sockets. This article explains how to manage system services on Linux using systemd. It cannot be used as is in environments with other initialization systems or where systemd is not running. For detailed commands, refer to the official systemctl manual.
The following apache2.service is an example when Apache is installed on Ubuntu. If it is not installed, the unit cannot be found, and the name may vary depending on the distribution. Before practicing, check the actual service name, and since stopping an operational web server or remote access service can disconnect your connection, use a safe test environment. Checking the status is often possible as a regular user, but changing system services usually requires administrator privileges.
Checking service status and name
Check the currently loaded services and installed service unit files separately. The two lists have different criteria, so the results may not be the same.
systemctl list-units --type=service --all
systemctl list-unit-files --type=service
The first shows services loaded in systemd, including inactive units. The second shows installed service unit files and their enabled status, which is also useful for finding services that have not been loaded yet. If the list is long and the pager opens, press q to exit.
For example, to check the status and recent logs of the Apache service, enter the following.
systemctl status apache2.service
systemctl is-active apache2.service
systemctl is-enabled apache2.service
In status output, Active: active (running) means the service is currently running, inactive means inactive, and failed means failed. Detailed states vary depending on the service type. is-active checks the current status, and is-enabled checks the enablement status. static units cannot be enabled in the usual way but can be started by other units.
Service start, stop, restart
The following commands actually change the service state. Replace the example service name with the one suitable for your system, and make sure that stopping the service is acceptable before executing.
sudo systemctl start apache2.service
sudo systemctl stop apache2.service
sudo systemctl restart apache2.service
start starts the service, and stop stops it. restart stops the service and then restarts it, and it can start a stopped service. Execute only the necessary command. After each operation, check the result with systemctl status apache2.service. Even for services already running, connections may be temporarily interrupted during a restart.
If the service supports reloading its own settings, you can reapply the settings with sudo systemctl reload apache2.service. The support and method of application vary for each service. Reload and restart are not the same action, and how to check the settings should follow the documentation of the service.
Activation at Boot and Current Running Status
The following commands configure or remove the connection so that units start during the boot process, etc. Running enable alone does not start anything immediately, and running disable alone does not immediately stop services that are already running.
sudo systemctl enable apache2.service
sudo systemctl disable apache2.service
systemctl is-enabled apache2.service
Select and execute only the necessary commands, and check the results with the last command. enabled is for activation, and disabled is for deactivation. However, services may still start due to dependencies from other units or sockets/timers, so do not interpret disable as blocking all startup paths.
To activate and start immediately, use sudo systemctl enable --now apache2.service; to deactivate and stop immediately, use sudo systemctl disable --now apache2.service. Check the effects of each command and practice only in a test environment.
What to Check When Problems Occur
Check the list of failed units and recent logs of specific services. Logs may contain sensitive information, so review the contents before sharing.
systemctl --failed
sudo journalctl -u apache2.service -n 50 --no-pager
If the service cannot be found, check its name and whether it is installed. If starting fails, check status and the logs for configuration errors, dependent services, port conflicts, or permission issues. The masked status indicates that starting is blocked, so do not release it arbitrarily before identifying the cause. The messages and solutions may vary depending on the distribution and service settings.
If you have changed the unit file
If you have modified the systemd unit file or drop-in configuration, use the following command to make systemd reread the unit definitions.
sudo systemctl daemon-reload
This command does not restart the service itself or make the service reload its configuration files. If you need to apply the changes to a running service, a separate restart or reload suitable for the service and changes may be required. Back up the configuration before making changes and ensure you know how to revert to the original state.




