systemctl Command Examples in Linux¶
Introduction¶
These examples show practical ways to use systemctl on a Linux terminal. Each example is written so you can adapt it for administration or troubleshooting.
Example 1: Basic Usage¶
systemctl status sshd
This is the simplest form of the command and is a good starting point before adding options.
Example 2: Common Admin Task¶
sudo systemctl restart sshd
This example reflects a common task on RHEL, Rocky Linux, AlmaLinux, or similar systems.
Example 3: Useful Option¶
sudo systemctl enable --now httpd
This option helps narrow the result, change behavior, or handle a more realistic target.
Example 4: Real-World Scenario¶
systemctl --failed
Use this pattern when the task moves beyond a single basic command.
Example 5: Verification¶
systemctl is-active sshd
Example output:
active
Common Mistakes¶
- Confusing
startwithenable; one affects now, the other affects boot. - Restarting remote access services without checking their configuration.
- Ignoring
journalctl -uwhen a service fails.
Quick Reference¶
systemctl status sshd
sudo systemctl restart sshd
sudo systemctl enable --now httpd
systemctl --failed
systemctl is-active sshd
Related Guides¶
- What is systemctl?
- systemctl enable vs start explained
- systemctl Troubleshooting Services
- systemctl interview questions
Summary¶
Good systemctl usage means choosing the right option, keeping the target clear, and verifying the result with output you can explain.