Linux for Developers Course
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

CommandWhat 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`?

Flash Cards

Question

Older command?

Click to reveal answer
Answer

The `service` command (e.g., `service nginx start`).

Question

start vs restart?

Click to reveal answer
Answer

`start` turns a stopped service on. If the service is already running, it does nothing. `restart` forcefully kills the currently running service and boots it back up fresh, which is required after changing configuration files.