Default system-provided systemd unit files are in /usr/lib/systemd/system
Custom unit files are in /etc/systemd/system
While modifying a unti file, do not edit the file in /usr/lib/systemd/system but create a custom file in /etc/systemd/system that is used as an overlay file.
In this tutorial, httpd service is used as example
service is one of the unit types (Refer 32.2 Monitoring --> 2.)
Install unit
Verify httpd installed or not
systemctl | grep "[Service Name]"
If the service hasn't installed, terminal will return nothing.
Example: systemctl | grep "httpd"
Install the unit
dnf install -y [Service Name]
Example: dnf install -y httpd
View the content of unit file
systemctl cat [Service Name].service
If the service hasn't installed, terminal will return No file found for [Service Name].service.
Press q to exit
Example: systemctl cat httpd.service
Edit unit
Open unit file by using vim text editor
sudo EDITOR=vim systemctl edit [Service Name].service
Example: sudo EDITOR=vim systemctl edit httpd.service
Edit unit file
Edit contents inside the space that fixed by unit file
Example result:
### Anything between here and the comment below will become the contents of the drop-in file
[Service]
Restart=always
RestartSec=5s
### Edits below this comment will be discarded
Save and exit
Esc --> :wq --> Enter
Reload systemd manager configuration
sudo systemctl daemon-reload
Verify the edited content of unit file
systemctl cat [Service Name].service
Drag to bottom
Press q to exit
Example: systemctl cat httpd.service
Restart the unit
sudo systemctl restart [Service Name].service
Example: sudo systemctl restart httpd.service
Testing
Find the Process ID of main process (2nd column)
The process ID which running as root (1st column) is the main process.
ps aux | grep [Service Name]
Example: ps aux | grep http
Kill the main process
kill -9 [Process ID]
Example: kill -9 9973
Check service status to verify it automatically restarted
systemctl status [Service Name]
Press q to exit
Example: systemctl status httpd
Cleanup
Stop the service
sudo systemctl stop [Service Name].service
Example: sudo systemctl stop httpd.service
Disable the service
sudo systemctl disable [Service Name].service
Example: sudo systemctl disable httpd.service
Remove the custom override directory
sudo rm -rf /etc/systemd/system/[Service Name].service.d
Example: sudo rm -rf /etc/systemd/system/httpd.service.d
Uninstall the apache package
sudo dnf remove -y [Service Name]
Example: sudo dnf remove -y httpd
Reload systemd manager configuration
sudo systemctl daemon-reload
Verify
systemctl cat [Service Name].service
If the service hasn't installed, terminal will return No file found for [Service Name].service.
Press q to exit
Example: systemctl cat httpd.service
Result
Install unit
student@localhost:~$ systemctl | grep "httpd"
student@localhost:~$ systemctl cat httpd.service
No files found for httpd.service.
student@localhost:~$ sudo dnf install -y httpd
[sudo] password for student:
Updating Subscription Management repositories.
Last metadata expiration check: 0:09:57 ago on Mon 17 Aug 2026 11:18:57 AM +08.
Dependencies resolved.
=============================================================================================================================================================
Package Architecture Version Repository Size
=============================================================================================================================================================
Installing:
httpd x86_64 2.4.63-13.el10_2.5 rhel-10-for-x86_64-appstream-rpms 56 k
Installing dependencies:
apr x86_64 1.7.5-3.el10 rhel-10-for-x86_64-appstream-rpms 127 k
apr-util x86_64 1.6.3-23.el10_1 rhel-10-for-x86_64-appstream-rpms 103 k
apr-util-lmdb x86_64 1.6.3-23.el10_1 rhel-10-for-x86_64-appstream-rpms 20 k
httpd-core x86_64 2.4.63-13.el10_2.5 rhel-10-for-x86_64-appstream-rpms 1.5 M
httpd-filesystem noarch 2.4.63-13.el10_2.5 rhel-10-for-x86_64-appstream-rpms 20 k
httpd-tools x86_64 2.4.63-13.el10_2.5 rhel-10-for-x86_64-appstream-rpms 90 k
redhat-logos-httpd noarch 100.3-2.el10 rhel-10-for-x86_64-appstream-rpms 22 k
Installing weak dependencies:
apr-util-openssl x86_64 1.6.3-23.el10_1 rhel-10-for-x86_64-appstream-rpms 22 k
mod_http2 x86_64 2.0.29-4.el10_2.2 rhel-10-for-x86_64-appstream-rpms 171 k
mod_lua x86_64 2.4.63-13.el10_2.5 rhel-10-for-x86_64-appstream-rpms 66 k
Transaction Summary
=============================================================================================================================================================
Install 11 Packages
Total download size: 2.2 M
Installed size: 6.0 M
Downloading Packages:
(1/11): apr-util-lmdb-1.6.3-23.el10_1.x86_64.rpm 11 kB/s | 20 kB 00:01
(2/11): redhat-logos-httpd-100.3-2.el10.noarch.rpm 11 kB/s | 22 kB 00:02
(3/11): apr-util-openssl-1.6.3-23.el10_1.x86_64.rpm 5.3 kB/s | 22 kB 00:04
(4/11): apr-util-1.6.3-23.el10_1.x86_64.rpm 16 kB/s | 103 kB 00:06
(5/11): apr-1.7.5-3.el10.x86_64.rpm 24 kB/s | 127 kB 00:05
(6/11): httpd-2.4.63-13.el10_2.5.x86_64.rpm 22 kB/s | 56 kB 00:02
(7/11): httpd-filesystem-2.4.63-13.el10_2.5.noarch.rpm 14 kB/s | 20 kB 00:01
(8/11): httpd-tools-2.4.63-13.el10_2.5.x86_64.rpm 28 kB/s | 90 kB 00:03
(9/11): mod_lua-2.4.63-13.el10_2.5.x86_64.rpm 46 kB/s | 66 kB 00:01
(10/11): httpd-core-2.4.63-13.el10_2.5.x86_64.rpm 74 kB/s | 1.5 MB 00:21
(11/11): mod_http2-2.0.29-4.el10_2.2.x86_64.rpm 4.6 kB/s | 171 kB 00:37
-------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 55 kB/s | 2.2 MB 00:41
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : apr-1.7.5-3.el10.x86_64 1/11
Installing : apr-util-lmdb-1.6.3-23.el10_1.x86_64 2/11
Installing : apr-util-openssl-1.6.3-23.el10_1.x86_64 3/11
Installing : apr-util-1.6.3-23.el10_1.x86_64 4/11
Installing : httpd-tools-2.4.63-13.el10_2.5.x86_64 5/11
Running scriptlet: httpd-filesystem-2.4.63-13.el10_2.5.noarch 6/11
Installing : httpd-filesystem-2.4.63-13.el10_2.5.noarch 6/11
Installing : httpd-core-2.4.63-13.el10_2.5.x86_64 7/11
Installing : mod_http2-2.0.29-4.el10_2.2.x86_64 8/11
Installing : mod_lua-2.4.63-13.el10_2.5.x86_64 9/11
Installing : redhat-logos-httpd-100.3-2.el10.noarch 10/11
Installing : httpd-2.4.63-13.el10_2.5.x86_64 11/11
Running scriptlet: httpd-2.4.63-13.el10_2.5.x86_64 11/11
Installed products updated.
Installed:
apr-1.7.5-3.el10.x86_64 apr-util-1.6.3-23.el10_1.x86_64 apr-util-lmdb-1.6.3-23.el10_1.x86_64 apr-util-openssl-1.6.3-23.el10_1.x86_64
httpd-2.4.63-13.el10_2.5.x86_64 httpd-core-2.4.63-13.el10_2.5.x86_64 httpd-filesystem-2.4.63-13.el10_2.5.noarch httpd-tools-2.4.63-13.el10_2.5.x86_64
mod_http2-2.0.29-4.el10_2.2.x86_64 mod_lua-2.4.63-13.el10_2.5.x86_64 redhat-logos-httpd-100.3-2.el10.noarch
Complete!
student@localhost:~$ systemctl cat httpd.service
# /usr/lib/systemd/system/httpd.service
# See httpd.service(8) for more information on using the httpd service.
# Modifying this file in-place is not recommended, because changes
# will be overwritten during package upgrades. To customize the
# behaviour, run "systemctl edit httpd" to create an override unit.
# For example, to pass additional options (such as -D definitions) to
# the httpd binary at startup, create an override unit (as is done by
# systemctl edit) and enter the following:
# [Service]
# Environment=OPTIONS=-DMY_DEFINE
[Unit]
Description=The Apache HTTP Server
Wants=httpd-init.service
After=network.target remote-fs.target nss-lookup.target httpd-init.service
Documentation=man:httpd.service(8)
[Service]
Type=notify
Environment=LANG=C
ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND
ExecReload=/usr/sbin/httpd $OPTIONS -k graceful
# Send SIGWINCH for graceful stop
KillSignal=SIGWINCH
KillMode=mixed
DevicePolicy=closed
KeyringMode=private
LockPersonality=yes
MemoryDenyWriteExecute=yes
OOMPolicy=continue
PrivateDevices=yes
PrivateTmp=true
student@localhost:~$ systemctl show httpd.service
Type=notify
ExitType=main
Restart=no
RestartMode=normal
NotifyAccess=main
RestartUSec=100ms
RestartSteps=0
RestartMaxDelayUSec=infinity
RestartUSecNext=100ms
TimeoutStartUSec=1min 30s
TimeoutStopUSec=1min 30s
TimeoutAbortUSec=1min 30s
TimeoutStartFailureMode=terminate
TimeoutStopFailureMode=terminate
RuntimeMaxUSec=infinity
RuntimeRandomizedExtraUSec=0
WatchdogUSec=infinity
WatchdogTimestampMonotonic=0
RootDirectoryStartOnly=no
RemainAfterExit=no
GuessMainPID=yes
MainPID=0
ControlPID=0
FileDescriptorStoreMax=0
NFileDescriptorStore=0
FileDescriptorStorePreserve=restart
StatusErrno=0
Result=success
ReloadResult=success
CleanResult=success
LiveMountResult=success
UID=[not set]
GID=[not set]
NRestarts=0
OOMPolicy=continue
ReloadSignal=1
Edit unit
student@localhost:~$ sudo EDITOR=vim systemctl edit httpd.service
student@localhost:~$ sudo systemctl daemon-reload
student@localhost:~$ systemctl cat httpd.service
# /usr/lib/systemd/system/httpd.service
# See httpd.service(8) for more information on using the httpd service.
# Modifying this file in-place is not recommended, because changes
# will be overwritten during package upgrades. To customize the
# behaviour, run "systemctl edit httpd" to create an override unit.
# For example, to pass additional options (such as -D definitions) to
# the httpd binary at startup, create an override unit (as is done by
# systemctl edit) and enter the following:
# [Service]
# Environment=OPTIONS=-DMY_DEFINE
[Unit]
Description=The Apache HTTP Server
Wants=httpd-init.service
After=network.target remote-fs.target nss-lookup.target httpd-init.service
Documentation=man:httpd.service(8)
# /usr/lib/systemd/system/httpd.service
# See httpd.service(8) for more information on using the httpd service.
# Modifying this file in-place is not recommended, because changes
# will be overwritten during package upgrades. To customize the
# behaviour, run "systemctl edit httpd" to create an override unit.
# For example, to pass additional options (such as -D definitions) to
# the httpd binary at startup, create an override unit (as is done by
# systemctl edit) and enter the following:
# [Service]
# Environment=OPTIONS=-DMY_DEFINE
[Unit]
Description=The Apache HTTP Server
Wants=httpd-init.service
After=network.target remote-fs.target nss-lookup.target httpd-init.service
Documentation=man:httpd.service(8)
[Service]
Type=notify
Environment=LANG=C
ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND
ExecReload=/usr/sbin/httpd $OPTIONS -k graceful
# Send SIGWINCH for graceful stop
KillSignal=SIGWINCH
KillMode=mixed
DevicePolicy=closed
KeyringMode=private
LockPersonality=yes
MemoryDenyWriteExecute=yes
OOMPolicy=continue
PrivateDevices=yes
PrivateTmp=true
ProtectClock=yes
ProtectControlGroups=yes
ProtectHome=read-only
ProtectHostname=yes
ProtectKernelLogs=yes
ProtectKernelModules=yes
ProtectKernelTunables=yes
ProtectSystem=yes
RestrictNamespaces=yes
RestrictRealtime=yes
RestrictSUIDSGID=yes
SystemCallArchitectures=native
[Install]
WantedBy=multi-user.target
# /etc/systemd/system/httpd.service.d/override.conf
[Service]
Restart=always
RestartSec=5s
Testing
student@localhost:~$ sudo systemctl restart httpd.service
student@localhost:~$ ps aux | grep httpd
root 9973 1.2 0.2 18856 10880 ? Ss 15:27 0:00 /usr/sbin/httpd -DFOREGROUND
apache 9974 0.0 0.1 18688 5308 ? S 15:27 0:00 /usr/sbin/httpd -DFOREGROUND
apache 9975 0.0 0.2 1567864 8088 ? Sl 15:27 0:00 /usr/sbin/httpd -DFOREGROUND
apache 9976 0.0 0.2 1436728 7836 ? Sl 15:27 0:00 /usr/sbin/httpd -DFOREGROUND
apache 10022 0.0 0.2 1436728 7836 ? Sl 15:27 0:00 /usr/sbin/httpd -DFOREGROUND
student 10161 0.0 0.0 227704 2208 pts/0 S+ 15:27 0:00 grep --color=auto httpd
student@localhost:~$ sudo kill -9 9973
student@localhost:~$ systemctl status httpd
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; preset: disabled)
Drop-In: /etc/systemd/system/httpd.service.d
└─override.conf
Active: active (running) since Tue 2026-08-18 15:30:05 +08; 9s ago
Invocation: a2a491372e154358a41f0d6dc1c7baed
Docs: man:httpd.service(8)
Main PID: 10245 (httpd)
Status: "Total requests: 0; Idle/Busy workers 100/0;Requests/sec: 0; Bytes served/sec: 0 B/sec"
Tasks: 177 (limit: 22995)
Memory: 13.3M (peak: 13.5M)
CPU: 167ms
CGroup: /system.slice/httpd.service
├─10245 /usr/sbin/httpd -DFOREGROUND
├─10246 /usr/sbin/httpd -DFOREGROUND
├─10247 /usr/sbin/httpd -DFOREGROUND
├─10248 /usr/sbin/httpd -DFOREGROUND
└─10265 /usr/sbin/httpd -DFOREGROUND
Aug 18 15:30:05 localhost.localdomain systemd[1]: httpd.service: Scheduled restart job, restart counter is at 1.
Aug 18 15:30:05 localhost.localdomain systemd[1]: Starting httpd.service - The Apache HTTP Server...
Aug 18 15:30:05 localhost.localdomain (httpd)[10245]: httpd.service: Referenced but unset environment variable evaluates to an empty string: OPTIONS
Aug 18 15:30:05 localhost.localdomain httpd[10245]: AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.l>
Aug 18 15:30:05 localhost.localdomain httpd[10245]: Server configured, listening on: port 80
Aug 18 15:30:05 localhost.localdomain systemd[1]: Started httpd.service - The Apache HTTP Server.
Cleanup
student@localhost:~$ sudo systemctl stop httpd.service
[sudo] password for student:
student@localhost:~$ sudo systemctl disable httpd.service
student@localhost:~$ sudo rm -rf /etc/systemd/system/httpd.service.d
student@localhost:~$ sudo dnf remove -y httpd
Updating Subscription Management repositories.
Dependencies resolved.
=============================================================================================================================================================
Package Architecture Version Repository Size
=============================================================================================================================================================
Removing:
httpd x86_64 2.4.63-13.el10_2.5 @rhel-10-for-x86_64-appstream-rpms 56 k
Removing unused dependencies:
apr x86_64 1.7.5-3.el10 @rhel-10-for-x86_64-appstream-rpms 302 k
apr-util x86_64 1.6.3-23.el10_1 @rhel-10-for-x86_64-appstream-rpms 220 k
apr-util-lmdb x86_64 1.6.3-23.el10_1 @rhel-10-for-x86_64-appstream-rpms 15 k
apr-util-openssl x86_64 1.6.3-23.el10_1 @rhel-10-for-x86_64-appstream-rpms 23 k
httpd-core x86_64 2.4.63-13.el10_2.5 @rhel-10-for-x86_64-appstream-rpms 4.7 M
httpd-filesystem noarch 2.4.63-13.el10_2.5 @rhel-10-for-x86_64-appstream-rpms 464
httpd-tools x86_64 2.4.63-13.el10_2.5 @rhel-10-for-x86_64-appstream-rpms 199 k
mod_http2 x86_64 2.0.29-4.el10_2.2 @rhel-10-for-x86_64-appstream-rpms 436 k
mod_lua x86_64 2.4.63-13.el10_2.5 @rhel-10-for-x86_64-appstream-rpms 138 k
redhat-logos-httpd noarch 100.3-2.el10 @rhel-10-for-x86_64-appstream-rpms 12 k
Transaction Summary
=============================================================================================================================================================
Remove 11 Packages
Freed space: 6.0 M
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Running scriptlet: httpd-2.4.63-13.el10_2.5.x86_64 1/11
Erasing : httpd-2.4.63-13.el10_2.5.x86_64 1/11
Running scriptlet: httpd-2.4.63-13.el10_2.5.x86_64 1/11
Erasing : mod_lua-2.4.63-13.el10_2.5.x86_64 2/11
Erasing : mod_http2-2.0.29-4.el10_2.2.x86_64 3/11
Erasing : redhat-logos-httpd-100.3-2.el10.noarch 4/11
Erasing : httpd-core-2.4.63-13.el10_2.5.x86_64 5/11
Erasing : httpd-tools-2.4.63-13.el10_2.5.x86_64 6/11
Erasing : httpd-filesystem-2.4.63-13.el10_2.5.noarch 7/11
warning: file /etc/systemd/system/httpd.service.d: remove failed: No such file or directory
Erasing : apr-util-1.6.3-23.el10_1.x86_64 8/11
Erasing : apr-1.7.5-3.el10.x86_64 9/11
Erasing : apr-util-lmdb-1.6.3-23.el10_1.x86_64 10/11
Erasing : apr-util-openssl-1.6.3-23.el10_1.x86_64 11/11
Running scriptlet: apr-util-openssl-1.6.3-23.el10_1.x86_64 11/11
Installed products updated.
Removed:
apr-1.7.5-3.el10.x86_64 apr-util-1.6.3-23.el10_1.x86_64 apr-util-lmdb-1.6.3-23.el10_1.x86_64 apr-util-openssl-1.6.3-23.el10_1.x86_64
httpd-2.4.63-13.el10_2.5.x86_64 httpd-core-2.4.63-13.el10_2.5.x86_64 httpd-filesystem-2.4.63-13.el10_2.5.noarch httpd-tools-2.4.63-13.el10_2.5.x86_64
mod_http2-2.0.29-4.el10_2.2.x86_64 mod_lua-2.4.63-13.el10_2.5.x86_64 redhat-logos-httpd-100.3-2.el10.noarch
Complete!
student@localhost:~$ sudo systemctl daemon-reload
student@localhost:~$ systemctl cat httpd.service
No files found for httpd.service.