Start and Configure Services

Red Hat Enterprise LinuxIntermediate
Practice Now

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 httpd service.
  • Check the status of the httpd service to confirm it is running.
  • Stop the httpd service.

Requirements

  • All commands that modify the system state must be executed with sudo.
  • Use the systemctl command to perform all service management operations.
  • At the end of this step, the httpd service 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 httpd service to start automatically at system boot.
  • Start the httpd service 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 systemctl command to enable the service.
  • At the end of this step, the httpd service 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.

✨ Check Solution and Practice✨ Check Solution and Practice