systemctl — Beginner's Guide (with Nginx Examples)
What is systemctl?
systemctl is the command-line tool used to control and manage systemd, the system and service manager used in many Linux distros like Ubuntu, Fedora, and Debian.
It lets you:
- Start, stop, restart, and check status of services (like Nginx)
- Enable or disable services to start on boot
- Manage system power actions (reboot, shutdown)
- Manage system states and units (services, sockets, timers, etc.)
Basic Terminology
- Service: A background program like the web server Nginx (
nginx.service), database (mysql.service), or SSH (ssh.service).
- Unit: systemd managed object such as services, mounts, devices, or timers.
- Enable: Set a service to start automatically when the system boots.
- Disable: Prevent a service from starting automatically on boot.
- Mask: Prevent a service from starting manually or automatically.
- Status: Shows the current running state and logs of a service.