What is systemctl daemon-reload in Linux?
Learn how systemd unit files work in Linux, explore the different unit types, and discover how to manage services with systemctl. Understand when to use daemon-reload, reload, or restart to apply configuration changes correctly.
When working with Linux systems, you will often need to create, modify, or troubleshoot systemd unit files. Whether you're configuring a custom service, adjusting a systemd timer, or changing service dependencies, you need to ensure that systemd recognizes your changes.
This is where the systemctl daemon-reload command comes into play.
What Is systemctl daemon-reload?
systemctl daemon-reload is a Linux command that instructs the systemd manager to reload its unit configuration files. This allows systemd to recognize newly created, modified, or removed unit files and update its understanding of the system's configuration.
Systemd is the system and service manager used by many Linux distributions, including Ubuntu, Debian, Fedora, and Red Hat Enterprise Linux (RHEL).
It manages system services, mount points, timers, sockets, and other system resources through unit files.
Whenever you modify a systemd unit file, systemd does not automatically detect every change. Running daemon-reload ensures that the system manager rereads the unit files and updates its configuration accordingly.
How to Use systemctl daemon-reload
The command is straightforward:
$ sudo systemctl daemon-reloadOnce executed, systemd reloads its unit definitions and rebuilds its dependency information.
Important: This command does not restart running services, stop processes, or reload application-specific configuration files.
It updates systemd's understanding of the unit files on disk.
When Should You Use systemctl daemon-reload?
You should run this command whenever you create, modify, or remove systemd unit files and want the system manager to recognize those changes.
Common scenarios include:
- Creating a new service: You have created a custom
.servicefile and need systemd to recognize it. - Modifying a service: You have changed directives such as
ExecStart=,User=,Group=, orRestart=. - Configuring a systemd timer: You have modified a
.timeror its associated.servicefile. - Changing dependencies: You have updated directives such as
After=,Requires=, orWants=. - Removing a unit file: You want systemd to refresh its configuration after deleting a unit file.
For example, suppose you create a custom service named myapp.service in /etc/systemd/system/.
After saving the file, run:
$ sudo systemctl daemon-reloadSystemd can now recognize the new unit.
You can verify this by checking its status:
$ systemctl status myapp.serviceIf the service is not running yet, you can start it:
$ sudo systemctl start myapp.serviceIf you want it to start automatically during boot, enable it separately:
$ sudo systemctl enable myapp.serviceRemember that recognizing a unit, starting a service, and enabling a service at boot are three different operations.
What Is the Difference Between daemon-reload, reload, and restart?
These commands serve different purposes, and understanding the distinction is essential for Linux system administration.
| Command | Purpose |
|---|---|
systemctl daemon-reload | Reloads systemd's unit definitions and dependency information. |
systemctl reload myapp.service | Requests that the running application reload its own configuration, if supported. |
systemctl restart myapp.service | Stops and starts the service again. |
systemctl reload-or-restart myapp.service | Reloads the service if supported; otherwise, restarts it. |
Consider a situation where you modify the ExecStart= directive in a service's unit file.
Running the following command makes systemd recognize the updated unit definition:
$ sudo systemctl daemon-reloadHowever, the currently running process does not automatically switch to the new command.
You will generally need to restart the service:
$ sudo systemctl restart myapp.serviceOn the other hand, if you change an application's configuration file rather than its systemd unit file, you generally do not need daemon-reload.
Instead, use the application's supported configuration-reload mechanism.
For example, after modifying an Nginx configuration file:
$ sudo nginx -t
$ sudo systemctl reload nginx.serviceThe first command validates the Nginx configuration, while the second asks Nginx to reload it.
Does systemctl daemon-reload Restart Running Services?
No. Running systemctl daemon-reload does not, by itself, restart or stop running services.
It instructs the systemd manager to reread unit files and update its internal configuration.
However, changes to a unit file may require additional action before they affect a running service.
For example, changing Restart=, User=, or ExecStart= does not automatically reconfigure an already running process. Depending on the directive, you may need to restart the service to apply the change.
This separation is particularly useful on production servers, where administrators may need systemd to recognize configuration changes without immediately interrupting running applications.
A Practical Example
Suppose you are running a custom Python application through a systemd service on Ubuntu.
Your unit file is located at:
/etc/systemd/system/myapp.serviceYou modify the service definition to change its execution command or environment variables.
A typical workflow would be:
Step 1: Edit the unit file.
$ sudo nano /etc/systemd/system/myapp.serviceStep 2: Reload systemd's unit definitions.
$ sudo systemctl daemon-reloadStep 3: Restart the service to apply the relevant changes.
$ sudo systemctl restart myapp.serviceStep 4: Verify that the service is running correctly.
$ sudo systemctl status myapp.serviceStep 5: Inspect the service logs if necessary.
$ sudo journalctl -u myapp.service -n 50 --no-pagerThis workflow ensures that systemd recognizes the updated unit file and that the application is restarted when necessary.
How Can You Verify That systemd Recognizes Your Changes?
After running daemon-reload, you can inspect the unit configuration that systemd has loaded.
For example:
$ systemctl cat myapp.serviceThis displays the unit file and any applicable drop-in configuration files.
To inspect a particular property, use:
$ systemctl show myapp.service -p ExecStartThis displays the ExecStart property as interpreted by systemd.
These commands are particularly useful when troubleshooting custom services or verifying changes on production systems.
The systemctl daemon-reload command is an essential tool for Linux system administrators working with systemd.
It ensures that systemd recognizes changes to unit files without automatically restarting running services. Whether you are creating custom services, configuring timers, or adjusting service dependencies, understanding when and why to use this command helps you manage Linux systems more reliably.
Remember: daemon-reload updates systemd's configuration, reload asks an application to reload its configuration, and restart starts the service again.
Understanding this distinction will help you troubleshoot systemd services and apply configuration changes with greater confidence.
Thank you for stopping by, and keep mastering Linux.