Progress: 0/62 (0%)
▶️ Starting, Stopping Services
Starting/Stopping Services
Continuing our restaurant analogy: Imagine a chef (service) who only works when needed. You, as the restaurant manager (systemd), can tell the chef to start cooking, stop cooking, or restart if something went wrong.
Continuing our restaurant analogy: Imagine a chef (service) who only works when needed. You, as the restaurant manager (systemd), can tell the chef to start cooking, stop cooking, or restart if something went wrong.
Starting a Service
sudo systemctl start <service-name>
sudo systemctl start nginx
This command starts the service immediately, but it won't start automatically on boot unless enabled.
Stopping a Service
sudo systemctl stop <service-name>
sudo systemctl stop nginx
This command stops the service right away.
Restarting a Service
sudo systemctl restart <service-name>
sudo systemctl restart nginx
This command stops and then starts the service immediately. Useful if a service is misbehaving or after configuration changes.
Quick Reference Table
| Action | Command | Example | Analogy |
|---|---|---|---|
| Start service | systemctl start | nginx | Chef starts cooking |
| Stop service | systemctl stop | nginx | Chef stops cooking |
| Restart | systemctl restart | nginx | Chef stops and starts again |
Real-life analogy
For starting: You tell the chef: "Start cooking now!" For stopping: You tell the chef: "Take a break, stop cooking!" For restarting: The chef burned the dish; you tell them: "Restart cooking from scratch!" This is the core of manually controlling services. Once you get the hang of this, we can make services start automatically on boot (next topic).