A packaged service may need a different restart delay or a higher resource limit on one machine. A systemd unit override keeps those local settings in a drop-in while the package continues to supply the main unit file.
systemd reads the main unit file first and applies drop-ins afterward. A drop-in can override individual settings or add dependencies. Removing an inherited dependency requires editing a full copy of the unit.
A manager reload makes the revised unit definition available the next time the service starts. A running service usually needs a restart to pick up settings such as a new open-file limit.
Steps to edit a systemd unit override:
- Inspect the configuration files for your unit, using its name in place of
override-demo.servicethroughout.$ systemctl cat override-demo.service # /usr/lib/systemd/system/override-demo.service [Unit] Description=Override demo service [Service] Type=simple ExecStart=/bin/sh -c "exec sleep infinity" Restart=on-failure RestartSec=5 LimitNOFILE=1024
Each drop-in appears in a separate file block. A block below /etc/systemd/system shows a local customization.
On Ubuntu and Debian, Apache's packaged start script sets its own open-file limit using APACHE_ULIMIT_MAX_FILES in /etc/apache2/envvars. To raise Apache's limit, change that setting because the start script applies it after systemd's LimitNOFILE.
Use systemctl --user cat unit.service for a per-user unit instead of the system manager.
- Check the unit's current open-file limits if you are adding or changing LimitNOFILE.
$ systemctl show -p LimitNOFILE -p LimitNOFILESoft override-demo.service LimitNOFILE=1024 LimitNOFILESoft=1024
In a soft:hard pair, the soft value should meet the service's needs. Keep the current hard value if it covers the new soft value. A hard-limit increase is needed only if the new soft value exceeds the current hard limit. For software that uses select(2), keep the soft limit at 1024.
- Open the unit's default drop-in override with the editor configured for systemctl.
$ sudo systemctl edit override-demo.service
Without --full, systemctl edits a drop-in instead of replacing the main unit file. The default drop-in for this system service is
/etc/systemd/system/override-demo.service.d/override.conf.For a separately named drop-in,
--drop-in=local.confselects local.conf. A change made with--runtimeexpires at the next boot. For a per-user service, the corresponding command issystemctl --user edit unit.service. - Add the directives under the original section name in the editable area above the discard marker.
The demo's 65535:65535 pair raises both limits from 1024. The LimitNOFILE line applies only when you are changing that limit. A single number sets both limits and can lower an existing hard limit.
[Service] RestartSec=15 LimitNOFILE=65535:65535
Each drop-in still needs normal section headers such as [Service] or [Unit]. If the section already exists in the editable area, add or replace only the settings you need under that header. The rest of the vendor unit stays in effect.
- Add an empty ExecStart= assignment immediately followed by the replacement assignment in the same [Service] section if you are replacing the inherited start command.
The second line uses the path to your executable and any arguments in place of
/path/to/app. The demo that changes RestartSec and LimitNOFILE skips this step.[Service] ExecStart= ExecStart=/path/to/app
Assigning an empty value to ExecStart= resets the inherited command list before the new command is added. The same pattern applies to other resettable list settings when entries must be removed or replaced.
Dependency settings such as After= and Requires= cannot be reset to an empty list in a drop-in. When dependencies must be removed, use sudo systemctl edit --full unit.service and review the whole copied unit carefully.
- Save the changes in the editor.
If you are editing an existing drop-in, keep a copy of its original settings before saving so you can restore them if the service fails to start.
- Close the editor.
When the editor exits successfully, systemctl installs the drop-in and reloads the manager.
A restart can interrupt active connections, so schedule it for a time when the interruption is acceptable. If the service fails to start, restore the previous drop-in or remove override.conf if you created it. A restored or removed drop-in requires sudo systemctl daemon-reload before you retry the restart.
- Confirm that systemd loaded the new drop-in after saving the editor changes.
$ systemctl show -p DropInPaths -p NeedDaemonReload override-demo.service DropInPaths=/etc/systemd/system/override-demo.service.d/override.conf NeedDaemonReload=no
NeedDaemonReload=no is the expected post-save result after a successful systemctl edit because the command reloads the manager automatically.
If the file was written with a regular editor instead of systemctl edit, run sudo systemctl daemon-reload before expecting the manager to see the new drop-in.
- Confirm the saved settings in the drop-in listed by systemctl cat.
$ systemctl cat override-demo.service # /usr/lib/systemd/system/override-demo.service [Unit] Description=Override demo service [Service] Type=simple ExecStart=/bin/sh -c "exec sleep infinity" Restart=on-failure RestartSec=5 LimitNOFILE=1024 # /etc/systemd/system/override-demo.service.d/override.conf [Service] RestartSec=15 LimitNOFILE=65535:65535
systemctl cat prints the backing files on disk in order, with the main unit file followed by its drop-ins.
- Restart the service so the running process picks up the changed unit settings.
$ sudo systemctl restart override-demo.service
Most service-unit override changes affect how systemd launches or constrains the service, so restart is the normal follow-up action. A service-specific reload usually rereads only the application's own configuration file.
- Check the service status after the restart.
$ systemctl status --no-pager --full override-demo.service * override-demo.service - Override demo service Loaded: loaded (/usr/lib/systemd/system/override-demo.service; static) Drop-In: /etc/systemd/system/override-demo.service.d `-override.conf Active: active (running) since Mon 2026-11-23 15:25:30 UTC; 37ms ago Invocation: <id> Main PID: 272 (sleep) Tasks: 1 (limit: 14378) Memory: 1.4M (peak: 1.7M) CPU: 3ms ##### snipped #####The Drop-In: directory proves that the override file is loaded for the running unit, and the fresh since timestamp shows that the service has been started again under the updated definition.
- Check the effective restart delay if you changed RestartSec.
$ systemctl show -p RestartUSec override-demo.service RestartUSec=15s
RestartUSec reports the value set by RestartSec. For a start command replacement, check the executable and arguments with
systemctl show -p ExecStart override-demo.service. - Check the running process's open-file limits if you changed LimitNOFILE and the service has a running main process, using the Main PID from status in place of 272.
$ awk '/^Max open files/ {print $4, $5}' /proc/272/limits 65535 65535The first column should match your chosen soft limit and the second should match your chosen hard limit.