Ubuntu systemctl Basics: status / start / restart / enable (Troubleshooting Guide)
What You'll Learn
- How to manage services (Nginx/Apache/SSH etc.) with
systemctlon Ubuntu - How to troubleshoot "not working", "need restart", "need auto-start" issues quickly
- Standard patterns for incident response
Quick Summary
Master these commands and you'll handle most situations:
- Check status:
systemctl status <service> - Start:
systemctl start <service> - Stop:
systemctl stop <service> - Restart:
systemctl restart <service> - Reload config:
systemctl reload <service>(if supported) - Enable auto-start:
systemctl enable <service> - Disable auto-start:
systemctl disable <service>
On Ubuntu, most commands require admin privileges, so add sudo.
Table of Contents
Prerequisites
- OS: Ubuntu
- systemd environment
- Permissions:
sudoaccess
1. What is systemctl?
systemctl is the systemd service management command.
You can start/stop/restart/check status of services running on the server (e.g., nginx, apache2, ssh, docker).
2. Start with "status"
Troubleshooting always starts here.
$ sudo systemctl status nginx
Key indicators:
Active: active (running)→ RunningActive: inactive (dead)→ StoppedActive: failed→ Failed (needs investigation)
For failed status, check logs with journalctl -u - that's the fastest path.
3. start/stop/restart
3-1. Start
$ sudo systemctl start nginx
3-2. Stop
$ sudo systemctl stop nginx
3-3. Restart
$ sudo systemctl restart nginx
After config changes, use restart.
If the service supports reload, you can use reload to apply changes without downtime.
4. reload / reload-or-restart
4-1. reload (only for supported services)
$ sudo systemctl reload nginx
4-2. reload-or-restart (safe fallback)
$ sudo systemctl reload-or-restart nginx
- Uses reload if supported
- Falls back to restart otherwise
5. Auto-start (enable/disable) - Common Beginner Issue
"It's running now, but stops after reboot" - this is the problem.
5-1. Enable auto-start
$ sudo systemctl enable nginx
5-2. Disable auto-start
$ sudo systemctl disable nginx
5-3. Check auto-start status
$ systemctl is-enabled nginx
Output:
enabled: Auto-start ONdisabled: Auto-start OFF
6. Troubleshooting "not working"
6-1. Check status
$ sudo systemctl status nginx
6-2. If failed, check logs (fastest path)
$ sudo journalctl -u nginx -n 200
Real-time tracking:
$ sudo journalctl -u nginx -f
6-3. Check config syntax first (e.g., nginx)
$ sudo nginx -t
If you restart with broken config, the service may stay down.
Check syntax first → restart if OK is the safe approach.
7. Finding Service Names
Service names vary by environment (e.g., Apache is apache2 on Ubuntu).
Search from list:
$ systemctl list-units --type=service | grep -i apache
List all (many results):
$ systemctl list-units --type=service
8. Common Pitfalls
8-1. status shows "running" but can't access
Even if the service is running, port binding, firewall, or application errors can prevent access.
Combine with "port connectivity (ss/lsof/nc/curl)" troubleshooting for faster resolution.
8-2. Enabled but not running
enable means "auto-start on next boot".
To start now, you also need start.
$ sudo systemctl enable nginx $ sudo systemctl start nginx
Summary (Copy-Paste Template)
# Check status sudo systemctl status <service> # Start/Stop/Restart sudo systemctl start <service> sudo systemctl stop <service> sudo systemctl restart <service> # Reload config (if supported) sudo systemctl reload <service> sudo systemctl reload-or-restart <service> # Auto-start sudo systemctl enable <service> sudo systemctl disable <service> systemctl is-enabled <service> # Logs sudo journalctl -u <service> -n 200 sudo journalctl -u <service> -f
Test Environment
Commands in this article were tested on Ubuntu 24.04 LTS / bash 5.2.