Systemd unit files are configuration files that specify how a system service should be started, stopped, and managed. Systemd is a system and service manager that controls the initialization of a Linux system, as well as manages system services during runtime.
The purpose of this blog is to explain the method to reload changes to Systemd unit files in Linux. The content of the post is:
How do I Reload Change to Systemd Unit Files?
In Linux, unit files have a specific structure that defines the properties of a service, including its dependencies, execution environment, and resource limits. These files are stored in the “/etc/systemd/system” directory, and they have a “.service” extension.
Reload All Services Unit Files
To reload changes to all the Systemd unit files on the Linux system, use the “systemctl” command below:
$ sudo systemctl daemon-reload
This will reload unit files and incorporate any changes made to them.
Reload a Specific Unit File
You can also reload a specific unit file using the “reload” command. For instance, reload the “snap-firefox-1232.mount” unit file by executing the below script:
$ sudo systemctl reload snap-firefox-1232.mount
After executing the command, “snap-firefox-1232.mount” unit files will be reloaded.
Note: Reloading a unit file only affects the running instance of the unit. We need to restart the unit if we want to apply changes made to a unit file to future boot-ups. It is possible by executing the “systemctl restart <unit_file>”.
How to Manage the Systemd Unit Files?
To manage the services of Systemd Unit Files and a particular unit file, follow the below instructions:
Check Services of Systemd Unit Files
To check the services of Systemd unit files, the “t” option is used that targets all services in the system:
$ systemctl -t service
The output shows all services of unit files with current status.
Check the Service Status of a Particular Unit File
Users can check the services of a particular unit file using the “status” option. For this, specify the service name “cron.service” and check the current status:
$ systemctl status cron.services
The output shows that “cron.service” is active.
The systemctl command can be used to control and manage unit files along with services as below:
$ systemctl start <unit_file> # start service $ systemctl stop <unit_file> # stop service $ systemctl enable <unit_file> # enable service
That is all from the systemd unit files.
To reload the changes to Systemd unit files, follow the “systemctl daemon-reload” command. Users can also reload the specific unit files used to manage many services, including network services, daemons, and other processes. This guide has explained the method to reload changes to Systemd unit files in Linux.