Stop, Start, and Troubleshoot Linux Services with systemctl
What you’ll learn: a quick‑look cheat sheet for the most common systemctl commands, why each one matters, and how to avoid the pitfalls that turn service management into a headache.
How systemctl Keeps Your Services Running
The heart of any modern Linux distro is systemd – and systemctl is the command line front‑door.
It lets you tell services to start or stop, reload configurations, enable them at boot, and inspect their status. Think of it as the Swiss Army tool for anything that runs in the background.
Starting and Stopping Services
1. systemctl start <service> – Fire up a service right now.
If you just installed a package or patched something, you’ll need to bring its daemon online without rebooting.
2. systemctl stop <service> – Bring it down cleanly.
A stale process can keep holding onto sockets; stopping it ensures the next start won’t hit “port already in use”.
3. systemctl restart <service> – Stop and start again in one shot.
You made a config change but don’t want to remember two commands.
4. systemctl reload <service> – Tell the daemon to reread its config without dropping connections.
Perfect for tweaking nginx or sshd; you get new rules instantly.
Enabling and Disabling Services
- systemctl enable – Add it to the boot sequence.
When you’re happy with a service, this makes sure it comes up after every reboot.
- systemctl disable – Remove it from startup.
Use this when you want to free up resources or prevent a service that’s no longer needed.
Checking Status and Logs
- systemctl status – One‑liner summary of what the daemon is doing, plus the last few log lines.
If your web server says “failed”, this will tell you if it’s out of memory, misconfigured, or blocked by SELinux.
- journalctl -u --since "5 minutes ago" – Dive deeper into logs for that service.
Scenario: After a kernel update, my VPN client stopped connecting. Running the above command revealed “permission denied” errors because the new kernel locked down some IPC resources. Fixing the policy resolved it.
Common Misconceptions
- “Systemctl is just another wrapper; you can use service instead.”
False. service calls older SysV init scripts, which may not understand modern features like dependency ordering or socket activation. Stick with systemctl for consistency.
- “If it’s in /etc/init.d/, I’ll have to keep using that.”
Not anymore. Even legacy scripts are now controlled by systemd units, and you can still manage them via systemctl.
Quick Reference Cheat Sheet
| Command | What It Does | Why You’d Use It |
|---|---|---|
| start | Bring a unit up immediately | After installing or patching |
| stop | Shut it down safely | Clean shutdown before reboot |
| restart | Stop then start | Apply config changes instantly |
| reload | Re-read config | Update without dropping connections |
| enable | Auto‑start at boot | Persistent services |
| disable | Prevent auto‑startup | Free resources or avoid unwanted services |
| status | Show current state + last logs | Quick health check |
| journalctl -u | Full log view for a unit | Debugging failures |
One More Trick: Masking Unwanted Services
If you ever want to make sure nobody can start a service, even root, use:
sudo systemctl mask <service>
It replaces the unit file with a symlink to /dev/null. The next time anyone tries systemctl start, it will refuse. Unmask it with unmask when you’re ready again.
That’s all there is to it – no more “mysterious daemon” drama. Just a handful of commands, a reason for each, and you can keep your Linux box humming.