Linux for Developers
/Intermediate
systemctl
Definition
The central management tool for systemd, which is the init system and service manager for most modern Linux distributions. It allows you to start, stop, enable, and view the status of services.
Explain Like I'm New
The master control switchboard for background applications. You use it to turn services (like a web server or database) on and off.
Real World Example
You install Nginx. It doesn't run automatically. You type `sudo systemctl start nginx`. To check if it's running, you type `systemctl status nginx`. It prints 'Active: active (running)'.
Common Use Cases
- •Managing server software
- •Checking service health
Service Management Commands
| Command | What it does |
|---|---|
| `start` | Turns the service on immediately. |
| `stop` | Turns the service off immediately. |
| `restart` | Kills the service and completely boots it up fresh. Drops all active user connections. |
| `reload` | Tells the active service to gracefully re-read its config file while keeping users connected. |
| `enable` | Configures the service to turn on automatically every time the server boots up. |
| `status` | Prints out if the service is running, failed, or dead, along with recent error logs. |
Interview Questions
basic
- What older command did `systemctl` replace for managing services?
intermediate
- What is the difference between `systemctl start` and `systemctl restart`?