Hello! Welcome back to your course on Linux system administration for web developers.
In our last lesson, we looked at the theory behind systemd. You learned that it's the master process (PID 1) that starts and supervises everything on your system, and that its behavior is defined by unit files. That was the "what" and "why." Today, we shift from theory to practice and focus on the "how."
This lesson is all about taking control. You'll learn the essential systemctl commands used to manage services. As a future full-stack developer, this is a skill you will use constantly, whether you're starting a web server, managing a database, or deploying your own Django application.
By the end of this 60-minute, hands-on lesson, you will be able to start, stop, restart, enable, and disable services on your Fedora system using the systemctl command.
1. Setting Up Our Practice Service
To learn how to manage services, we first need a service to manage. We'll use the Apache HTTP Server, a very common web server. On Fedora, its package and service name is httpd. This is a perfect example as it's directly related to your web development goals.
Open your terminal and install it using dnf:
sudo dnf install httpd
This command will install the web server software and its corresponding systemd service unit file.
2. The Six Essential systemctl Commands
The systemctl command is your primary tool for interacting with systemd. While it has many options, your day-to-day work will revolve around six key actions: status, start, stop, restart, enable, and disable.
Let's watch a detailed video that walks through these commands using the very service we just installed, httpd on Fedora.
Systemd Explained: How to Manage Linux Services Easily
This video from Learn Linux TV provides a practical demonstration of the most common systemctl commands. The presenter uses Fedora and the httpd service, which perfectly matches our learning environment.
Watch the following segments carefully: Checking Status (07:13 - 09:40): See how to use systemctl status to check if httpd is running. Pay attention to the inactive and disabled states. Starting and Stopping (09:40 - 11:40): Observe the systemctl start and systemctl stop commands in action. Restarting (11:40 - 12:26): Understand the purpose of systemctl restart. Enabling and Disabling (12:26 - 15:12): This is crucial. Learn how systemctl enable and systemctl disable control whether a service starts at boot. Summary (15:12 - 15:45): A quick recap of the six commands you just learned.
3. Reviewing the Commands
Let's break down what you just saw in the video. These are the commands you'll use most often. Note that making changes to a service's state (like starting or stopping it) requires administrative privileges, so we use sudo.
Checking Status
This is your go-to command for troubleshooting. It tells you if a service is running, if it's enabled to start at boot, and shows the most recent log entries.
systemctl status httpd.service
Controlling the Current Session
These commands affect the service right now but don't change what happens after a reboot.
sudo systemctl start httpd.service- Starts the service.sudo systemctl stop httpd.service- Stops the service.sudo systemctl restart httpd.service- Stops and then immediately starts the service. This is useful for making a configuration change take effect.

Controlling Boot-Time Behavior
These commands determine if a service will start automatically when you boot your system. They work by creating or removing symbolic links in systemd's configuration directories, which you learned about in the previous lesson.
sudo systemctl enable httpd.service- Ensures the service starts on the next boot.sudo systemctl disable httpd.service- Prevents the service from starting on the next boot.
A key point that the video highlights is the difference between Linux families. On Fedora and other Red Hat-based systems, services are typically not enabled by default after installation. On Debian/Ubuntu systems, they often are. This is a deliberate choice: Fedora doesn't assume you want a service running just because you installed it.
4. Advanced Control and Shortcuts
The six basic commands cover most situations, but there are a few more tricks that will make you more efficient. A great article from Last9 provides a concise reference for these.
systemctl: The Complete Guide to Managing Linux Services
This guide provides an excellent written summary of systemctl commands and introduces some powerful variations like reload and the --now flag.
Read the sections "How to Start, Stop, and Restart Services the Right Way" and "How to Enable or Disable Services at Boot". Focus on two new concepts: The reload command: How is it different from restart? The --now flag: How can it save you from typing a second command?
As you just read, here are two major takeaways for professional service management:
reloadvsrestart: When you modify a service's configuration file (e.g., changing a setting for your Nginx web server), you need the service to read the new configuration.restartwill stop the service completely and start it again, which causes a brief service interruption.reload, if the service supports it, tells the service to re-read its configuration files without stopping. For a live web server,reloadis always preferred as it avoids downtime.- The
--nowflag: This is a fantastic timesaver. Instead of runningsudo systemctl enable my-serviceand thensudo systemctl start my-service, you can do it all in one go:sudo systemctl enable --now my-service. The same works for disabling and stopping:sudo systemctl disable --now my-service.
5. Do-It-Yourself: Managing the Web Server
Time to put this into practice. Follow these steps in your terminal to get a feel for the complete service lifecycle.
-
Initial State: First, ensure the web server is stopped and disabled. This gives us a clean slate.
sudo systemctl disable --now httpdVerify this by checking its status.
systemctl status httpdThe output should show
inactive (dead)anddisabled. -
Enable and Start: Now, use a single command to both enable the service to start at boot and start it for the current session.
sudo systemctl enable --now httpd -
Verify It's Running: Confirm the service is active in two ways:
- Check the status with
systemctl. It should showactive (running)andenabled.
systemctl status httpd- Open your web browser and navigate to
http://localhost. You should see the Fedora test page. This is the ultimate confirmation that your web server is working!
- Check the status with
-
Restart the Service: Practice restarting the service.
sudo systemctl restart httpdRefresh your browser. You might notice a very brief loading flicker, but the page should still appear, as the restart is very fast.
-
Stop the Service: Finally, stop the service.
sudo systemctl stop httpdVerify it's stopped by checking the status and by refreshing your browser—the page should now fail to load.
Conclusion
Excellent work! You've moved from understanding the theory of systemd to practically commanding it. You now hold the keys to controlling the fundamental services on your Linux system—a core competency for any system administrator or developer who deploys their own code.
Key Takeaways:
- The
systemctlcommand is the primary tool for managingsystemdservices. start,stop, andrestartcontrol a service in the current session.enableanddisablecontrol a service's behavior at boot time.- You can combine actions with the
--nowflag (e.g.,enable --now) to work more efficiently. reloadis preferred overrestartfor applying configuration changes to a live service to avoid downtime.
We've seen how to start and stop services, but what happens when a service fails to start? The systemctl status command gives us hints, but to really dig in, we need to look at the logs. In our next lesson, we'll do just that by learning to use journalctl to query the systemd journal and troubleshoot service issues.