What this is
This guide teaches you how to restart Linux services correctly using systemctl (systemd).
What it is for
- Apply configuration changes (example: Nginx, Apache, SSH)
- Recover a stuck service
- Verify a service is running and healthy
Prerequisites
- SSH access
- Sudo privileges
- Know the service name (examples:
nginx,apache2,sshd,mysql)
Step-by-step
Step 1) Identify the service name
Command (search):
systemctl list-units --type=service | grep -i nginx
What it does: Lists services and filters by name.
Expected output: A line containing something like nginx.service.
Step 2) Check current status (before restarting)
sudo systemctl status nginx --no-pager
What it does: Shows whether the service is running and recent messages.
Expected output: Active: active (running) if healthy.
Step 3) Restart the service
sudo systemctl restart nginx
What it does: Stops and starts the service.
Why it is needed: Applies config changes and resets the process.
Expected output: Usually no output if successful.
Step 4) Verify status after restart
sudo systemctl status nginx --no-pager
Expected output: Active: active (running).
Step 5) If it fails: check logs
sudo journalctl -u nginx -n 50 --no-pager
What it does: Shows the last 50 log lines for that service.
Useful commands & notes
Reload vs restart (important)
- Reload applies configuration without fully stopping (if supported).
- Restart fully stops and starts the service.
Reload command:
sudo systemctl reload nginx
Enable service at boot
sudo systemctl enable nginx
Start/stop manually
sudo systemctl stop nginx
sudo systemctl start nginx
Final verification
For web servers, also check the port is listening:
sudo ss -lntp | grep -E ":80|:443"
Expected output: A line showing the process listening on port 80/443.
Conclusion
You now know how to restart and verify Linux services safely using systemctl and journalctl.