Change a systemd Service with a Drop-In Override
Before you begin
- Applies to:Linux hosts running systemd.
- Where to start:Open a shell on the affected host. Keep it open so the later steps reuse the service name set in Step 1.
- What you need:Have sudo access and an existing test service. Find its unit name with systemctl list-units --type=service --all. Arrange a maintenance window before restarting a production service.
Guide tools
systemd drop-ins let an administrator adjust a packaged unit without editing the vendor’s unit file. This guide uses a harmless scheduling-priority change as an example. Use a lab service first; restarting a production service can interrupt applications.
Inspect the Unit and Its Existing Overrides
Read FirstChoose an existing service and inspect its vendor unit, merged definition, current state, and any drop-in paths before changing it. Replace example.service with a real unit name.
unit=example.servicesystemctl status "$unit" --no-pagersystemctl cat "$unit"systemctl show "$unit" -p FragmentPath -p DropInPaths -p Nice❯ Illustrative Output (Results Vary)
FragmentPath=/usr/lib/systemd/system/example.serviceDropInPaths=Nice=0
Terminal: Confirm systemd loaded the drop-in and the service remains active.
Create a Small Local Override
Drop-InUse systemctl edit to create /etc/systemd/system/UNIT.d/override.conf. If an override already exists, review it and preserve its settings. The example raises the unit’s nice value, giving it a lower CPU scheduling priority. The exact effect is workload-dependent; avoid changing resource controls without measuring the impact.
sudo systemctl edit "$unit"Add the example above the boundary comment if the editor displays one. The text below that boundary is reference material and is discarded when you save. If the editable area already has a [Service] section, add or update Nice=5 there and preserve the other settings:
[Service]Nice=5What to press · In nano, press Ctrl+O, Enter, then Ctrl+X. In Vim, press i before editing, then press Esc, type :wq, and press Enter. In Step 3, check that systemctl cat lists the drop-in and that systemctl show reports Nice=5 after reloading the unit configuration. Step 4 covers applying the change to the running service.
❯ Illustrative Output (Results Vary)
Created /etc/systemd/system/example.service.d/override.confReload and Review the Merged Unit
Configuration CheckAfter writing a drop-in, reload systemd’s manager configuration. Then inspect the merged unit and property value. A daemon reload does not itself restart the service.
What you should see · DropInPaths lists your override and Nice is 5 for this example.
If you see something else · If the override is absent, return to Step 2 and check that you saved above the editor boundary. If the value differs, inspect the files listed by systemctl cat for a later setting. Continue to the approved restart in Step 4 only after the merged value is correct.
sudo systemctl daemon-reloadsystemctl cat "$unit"systemctl show "$unit" -p DropInPaths -p Nice❯ Illustrative Output (Results Vary)
DropInPaths=/etc/systemd/system/example.service.d/override.confNice=5Apply Only During an Approved Restart Window
Service ImpactSome properties affect newly started processes, so the running process may not reflect the change until restarted. Check application health requirements, dependencies, and maintenance timing before restarting the real service.
# In a lab, or during an approved maintenance window:sudo systemctl restart "$unit"systemctl is-active "$unit"systemctl show "$unit" -p Nicejournalctl -u "$unit" --since '10 minutes ago' --no-pager❯ Illustrative Output (Results Vary)
activeNice=5Remove Only Your Override When Reverting
RollbackReopen the override and remove only the Nice=5 line added for this example. Preserve any other directives. Restore the previous Nice value if you changed an existing directive. Saving an empty edit cancels the change. If the file was created solely for this lab, inspect it first and remove just that file using the command below. Reload and verify the baseline from Step 1.
sudo systemctl edit "$unit"# Edit and save if the file contains other settings. If it was created solely# for this lab, exit the editor, inspect the file, then remove only that file:# sudo cat -- "/etc/systemd/system/${unit}.d/override.conf"# sudo rm -i -- "/etc/systemd/system/${unit}.d/override.conf"sudo systemctl daemon-reloadsystemctl show "$unit" -p DropInPaths -p NiceIf you already restarted the service with the changed setting, repeat the approved restart and workload checks from Step 4 to apply the restored setting.
❯ Illustrative Output (Results Vary)
Nice=0Further reading: systemctl manual and systemd unit drop-in configuration.
Your feedback keeps these production procedures accurate and battle-tested.