Start and Configure Services

LinuxLinuxBeginner
Practice Now

Introduction

In this challenge, you will learn how to start, stop, and configure services to start automatically at system boot. This is an essential skill for system administrators to manage services effectively in a Linux environment.


Skills Graph

%%%%{init: {'theme':'neutral'}}%%%% flowchart RL linux(("`Linux`")) -.-> linux/BasicSystemCommandsGroup(["`Basic System Commands`"]) linux/BasicSystemCommandsGroup -.-> linux/echo("`Text Display`") subgraph Lab Skills linux/echo -.-> lab-389477{{"`Start and Configure Services`"}} end

Start and Stop Services

Tasks

  • Start the httpd service
  • Stop the httpd service

Requirements

  • All operations should be performed as the labex user
  • Use the appropriate systemd commands to start and stop the httpd service

Example

After starting the httpd service, you should see the following output when running systemctl status httpd:

● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
   Active: active (running) since Wed 2023-04-12 10:00:00 UTC; 10s ago
 Main PID: 12345 (httpd)
   Status: "Running, listening on: port 80"
   CGroup: /system.slice/httpd.service
           ├─12345 /usr/sbin/httpd -DFOREGROUND
           ├─12346 /usr/sbin/httpd -DFOREGROUND
           └─12347 /usr/sbin/httpd -DFOREGROUND

And after stopping the httpd service, you should see the following output when running systemctl status httpd:

● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
   Active: inactive (dead) since Wed 2023-04-12 10:00:30 UTC; 10s ago
 Main PID: 12345 (code=exited, status=0/SUCCESS)

Configure Services to Start Automatically at Boot

Tasks

  • Configure the httpd service to start automatically at system boot
  • Verify that the httpd service starts automatically after a system reboot

Requirements

  • All operations should be performed as the labex user
  • Use the appropriate systemd commands to enable the httpd service to start automatically at boot

Example

After enabling the httpd service to start automatically at boot, you should see the following output when running systemctl status httpd:

● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
   Active: active (running) since Wed 2023-04-12 10:00:00 UTC; 10s ago
 Main PID: 12345 (httpd)
   Status: "Running, listening on: port 80"
   CGroup: /system.slice/httpd.service
           ├─12345 /usr/sbin/httpd -DFOREGROUND
           ├─12346 /usr/sbin/httpd -DFOREGROUND
           └─12347 /usr/sbin/httpd -DFOREGROUND

Summary

In this challenge, you learned how to start, stop, and configure services to start automatically at system boot. You practiced using systemd commands to manage the httpd service, which is an essential skill for system administrators. By completing this challenge, you have demonstrated your ability to deploy, configure, and maintain systems by managing services effectively.

If you need to set up the initial environment for this challenge, you can use the following setup.sh script:

#!/bin/bash

## Install the httpd package
sudo yum install -y httpd

This script will install the httpd package, which is required for this challenge. You can run the script as the labex user to set up the initial environment.

Other Linux Tutorials you may like