Managing Services in RHEL 7 Part 1
Managing Services in RHEL 7 Part 1
RHEL 7 - Part 1
Understanding and Controlling System Services
Your Name
Date
by محمد السوادي
Introduction
What are Services? Why Manage Services?
Services are background processes that provide Start, stop, or restart services as needed.
functionality to the system (e.g., web servers, databases,
Enable or disable services to start automatically at boot.
network services).
Troubleshoot and monitor service status.
Examples: httpd (Apache web server), sshd (SSH server),
firewalld (firewall).
Systemd Overview
What is Systemd? Key Features of Systemd:
Systemd is the system and service manager in RHEL 7. Manages services, devices, mounts, and sockets.
It replaces the older SysVinit system. Provides faster boot times and parallel service startup.
Files with a .service extension that define how a service should be [Unit]
managed. Description=Apache HTTP Server
After=network.target
Located in /usr/lib/systemd/system/ or /etc/systemd/system/.
[Service]
User=apache
Group=apache
ExecStart=/usr/sbin/httpd
ExecReload=/bin/kill -HUP $MAINPID
ExecStop=/bin/kill -INT $MAINPID
[Install]
WantedBy=multi-user.target
Listing Services
Command 1: systemctl list-unit-files Command 2: systemctl list-units
Purpose: Lists all available service units. Purpose: Lists currently active units.
Example: Example:
Explanation: Displays all service units and their status Explanation: Shows active, loaded, and running services.
(enabled/disabled).
Starting and Stopping Services
Command 1: systemctl Command 2: systemctl Command 3: systemctl
start stop restart
Explanation: Starts the Apache web Explanation: Stops the Apache web Explanation: Restarts the Apache
server (httpd). server. web server.
Enabling and Disabling Services
Command 1: systemctl enable Command 2: systemctl disable
Purpose: Enables a service to start at boot. Purpose: Disables a service from starting at boot.
Example: Example:
Explanation: Ensures the Apache web server starts Explanation: Prevents the Apache web server from starting
automatically on system boot. automatically on boot.
Checking Service Status
Command: systemctl status
Example:
Explanation: Shows whether the service is active, inactive, or failed, along with recent log entries.