If you’re new to Ubuntu or any Linux distribution, you might wonder what keeps your system running smoothly—things like Wi-Fi, printing, or even the login screen. The answer is Linux services, managed in Ubuntu by systemd
and controlled with systemctl
. These terms might sound complex, but they’re just tools that make your system work. In this tutorial, we’ll break them down step-by-step, explain why they’re crucial, and show you how to use them. Understanding the "why" will help you grasp the bigger picture.
What Are Linux Services, and Why Do They Matter?
Services are programs that run in the background, handling tasks your system needs. Think of them as the engine under the hood of your Ubuntu machine. For example:
- A networking service connects you to the internet.
- A printing service (like
cups
) talks to your printer. - A web server service (like
apache2
) delivers websites.
Why they’re important: Your computer isn’t just one big program—it’s a team of smaller ones working together. Services are the specialists. Without them, your system would be a blank slate, unable to browse the web or share files. Managing them lets you decide what runs, fix issues, and optimize performance.
In Ubuntu, systemd
is the system that oversees these services. Let’s explore that next.
What Is systemd, and Why Should You Care?
systemd
is the master controller of your Ubuntu system. It’s a program that starts when your computer boots and manages services, hardware, and other system tasks. It replaced an older system called init
because it’s smarter and faster.
Why it’s important: When you turn on your computer, lots of things need to happen—your network has to start, your drives need to mount, and your desktop needs to load. systemd
figures out the order and timing, like a conductor leading an orchestra. It’s clever enough to start services in parallel (at the same time) when possible, which makes your system boot faster than older methods. It also keeps services running smoothly and restarts them if they crash. Think of it as the behind-the-scenes hero ensuring your system “just works” when you log in.
You don’t talk to systemd
directly, though—you use systemctl
, a command-line tool. Let’s see how it works.
Meet systemctl
: Your Command Center
systemctl
is how you tell systemd what to do with services. Want to start a service? Stop it? Check if it’s running? systemctl
is your go-to. It’s like a remote control for your system’s engine.
Why it’s important: Services aren’t perfect—they can fail, slow down, or need a tweak. systemctl
gives you precise control without rebooting your whole system. If your web server stops working, you can restart it in seconds instead of waiting minutes for a full restart. It’s efficient, keeps your system responsive, and gives you the power to fix things or experiment with a few commands.
Let’s try it out. Open your terminal (press Ctrl + Alt + T
in Ubuntu), and follow these hands-on steps.
Step 1: See What’s Running
To get a list of active services, type:
systemctl list-units --type=service --state=active
You’ll see stuff like snapd
(for Snap apps), systemd-networkd
(for networking), or bluetooth
. Each line shows a service name and what it does.
Why it’s important: Your system might be running dozens of services, and not all are obvious. This command reveals what’s active, so you can spot trouble—like a missing network service if your Wi-Fi’s down—or identify resource hogs slowing your system. It’s like peeking under the hood to figure out what makes your system tick.
Step 2: Check a Service’s Status
Let’s check a specific service, like ssh
(used for remote access, if installed). Type:
systemctl status ssh
You’ll get:
- Active (running)” or “Inactive” to show if it’s on.
- How long it’s been running.
- Recent logs (handy for spotting errors).
Why it’s important: Services can fail silently. This command shows you their health—like a doctor’s checkup. If ssh is “dead,” you know why you can’t log in remotely. The logs give clues to fix it, making it your go-to troubleshooting tool.
Step 3: Control Services Like a Boss
Now, let’s play with a service. To stop ssh:
sudo systemctl stop ssh
(sudo means “do this as the boss”—services need that authority.)
To start it:
sudo systemctl start ssh
To restart it (stop and start in one go):
sudo systemctl restart ssh
Why it’s important: Services can crash or freeze, especially after updates or heavy use. Restarting refreshes them without rebooting your whole system, saving time and keeping other tasks running. Stopping unused services frees up memory and CPU power. It’s like flipping a switch to fix something or save energy!
Step 4: Decide What Runs at Boot
Some services start automatically when your system powers on—like networking or your desktop. Others wait for your command.
To make ssh start at boot:
sudo systemctl enable ssh
To stop it from auto-starting:
sudo systemctl disable ssh
Why it’s important: Every auto-starting service uses resources (RAM, CPU) and adds time to your boot. Disabling ones you don’t need—like bluetooth if you don’t use it—makes your system leaner and faster. Enabling critical ones ensures they’re ready when you need them. You get to customize your system, tailoring it to your needs.
Real-World Example: Running a Web Server
Let’s say you installed Apache
(a web server) with sudo apt install apache2
.
Check it:
systemctl status apache2
If it’s off, start it:
sudo systemctl start apache2
Make it run at boot:
sudo systemctl enable apache2
Now your website’s live! Open a browser and type localhost
to see it.
Why it’s important: This is how real websites work. Servers run 24/7 thanks to systemd keeping services alive. You’re learning the foundation of server management, and you just built a mini website—pretty cool, right?
Common Services to Explore
Here are a few you’ll see in Ubuntu:
systemd-networkd
: Keeps your internet alive.
bluetooth
: Runs Bluetooth devices.
cups
: Manages printing.
snapd
: Handles Snap packages.
Try systemctl status [name]
to check them out!
Why This Matters to You
Understanding systemd
and systemctl
isn’t just about typing commands—it’s about seeing how Ubuntu works under the surface. You’re not just clicking buttons; you’re controlling the system’s core. Need to fix a crashed service? Speed up your boot? Host a website? You’ve got the tools now.
Experiment with these commands. Start and stop a service, check its status, and watch what happens. The more you play, the more you’ll learn. You’re on your way to mastering Linux services—enjoy the ride!
Top comments (0)