Introduction
Welcome to this challenge on managing system services. Services, also known as daemons, are programs that run in the background to provide essential functionalities. In this challenge, you will learn the fundamental skills of starting, stopping, and enabling services using the systemd service manager. These are core competencies for any Linux system administrator.
Start and Stop a Service
Your first task is to manage the Apache HTTP Server service, httpd. You will practice starting the service, checking its status, and then stopping it.
Tasks
- Start the
httpdservice. - Check the status of the
httpdservice to confirm it is running. - Stop the
httpdservice.
Requirements
- All commands that modify the system state must be executed with
sudo. - Use the
systemctlcommand to perform all service management operations. - At the end of this step, the
httpdservice should be in a stopped state.
Example
After starting the httpd service, running sudo systemctl status httpd should show an active (running) state.
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
Active: active (running) since Mon 2024-05-20 10:00:00 UTC; 5s ago
Main PID: 1234 (httpd)
Tasks: 4 (limit: 11079)
Memory: 9.8M
CPU: 55ms
CGroup: /system.slice/httpd.service
├─1234 /usr/sbin/httpd -DFOREGROUND
├─1235 /usr/sbin/httpd -DFOREGROUND
└─1236 /usr/sbin/httpd -DFOREGROUND
After stopping the service, the status will change to inactive (dead).
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
Active: inactive (dead)
Configure a Service to Start Automatically
Simply starting a service does not guarantee it will be running after a system reboot. To ensure a service starts automatically when the system boots up, you must "enable" it. In this step, you will enable the httpd service.
Tasks
- Configure the
httpdservice to start automatically at system boot. - Start the
httpdservice to make it active in the current session. - Verify that the service is both enabled and running.
Requirements
- All commands that modify the system state must be executed with
sudo. - Use the
systemctlcommand to enable the service. - At the end of this step, the
httpdservice should be both enabled and running.
Example
After enabling and starting the service, the output of sudo systemctl status httpd will show both active (running) and enabled in the Loaded line.
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
Active: active (running) since Mon 2024-05-20 10:05:00 UTC; 10s ago
Main PID: 5678 (httpd)
Tasks: 4 (limit: 11079)
Memory: 9.9M
CPU: 50ms
CGroup: /system.slice/httpd.service
├─5678 /usr/sbin/httpd -DFOREGROUND
├─5679 /usr/sbin/httpd -DFOREGROUND
└─5680 /usr/sbin/httpd -DFOREGROUND
Notice the word enabled in the Loaded line, which confirms the service is configured to start on boot.
Summary
In this challenge, you have learned the essential systemd commands for managing services on a Red Hat Enterprise Linux system. You practiced using sudo systemctl start to activate a service, sudo systemctl stop to deactivate it, and sudo systemctl enable to ensure it starts automatically on boot. You also learned how to check the current state of a service with sudo systemctl status. Mastering these commands is a critical step in becoming a proficient system administrator.



