🎁 New User? Get 20% off your first purchase with code NEWUSER20 Register Now →
Menu

Categories

systemctl Command

Beginner Systemd & Services man(1)

Control the systemd system and service manager

👁 11 views 📅 Updated: Mar 15, 2026
SYNTAX
systemctl [OPTION]... COMMAND [UNIT]

What Does systemctl Do?

systemctl is the primary command for managing systemd services, the init system used by most modern Linux distributions. It starts, stops, restarts, enables, and checks the status of system services.

systemd manages the entire system lifecycle: services, timers, mounts, targets, and more. systemctl is the interface to control and inspect all of these units.

systemctl replaced the older service and chkconfig commands. Understanding systemctl is essential for managing any modern Linux server.

Options & Flags

OptionDescriptionExample
start Start a service sudo systemctl start nginx
stop Stop a service sudo systemctl stop nginx
restart Restart a service sudo systemctl restart nginx
reload Reload config without restart sudo systemctl reload nginx
status Show service status systemctl status nginx
enable Enable on boot sudo systemctl enable nginx
disable Disable on boot sudo systemctl disable nginx
is-active Check if running systemctl is-active nginx
list-units List active units systemctl list-units --type=service

Practical Examples

#1 Check service status

Shows if nginx is running, enabled, and recent log entries.
$ systemctl status nginx
Output: ● nginx.service - A high performance web server Active: active (running) since Mon 2024-01-15 Main PID: 1234 (nginx)

#2 Start and enable

Starts nginx AND enables it to start on boot in one command.
$ sudo systemctl enable --now nginx

#3 Restart service

Stops and starts the PHP-FPM service.
$ sudo systemctl restart php-fpm

#4 List all services

Shows all currently running services.
$ systemctl list-units --type=service --state=running

#5 Check if enabled

Shows if the service starts on boot.
$ systemctl is-enabled nginx
Output: enabled

#6 View failed services

Shows all services that failed to start.
$ systemctl --failed

#7 Reload systemd

Reloads systemd after modifying .service files.
$ sudo systemctl daemon-reload

#8 Mask a service

Completely prevents a service from starting (even manually).
$ sudo systemctl mask dangerous-service

Tips & Best Practices

enable --now: systemctl enable --now service starts it immediately AND enables on boot. Saves a separate start command.
daemon-reload after changes: After modifying a .service file, run systemctl daemon-reload before restart. Otherwise systemd uses the old config.
mask vs disable: disable prevents auto-start. mask prevents ALL starting (even manual). Use mask for dangerous services.

Frequently Asked Questions

How do I start a service?
sudo systemctl start service_name. Add enable to start on boot: sudo systemctl enable --now service_name.
How do I check why a service failed?
systemctl status service shows status and recent logs. journalctl -u service shows full logs.
How do I make a service start on boot?
sudo systemctl enable service_name. Use enable --now to also start it immediately.

Master Linux with Professional eBooks

Curated IT eBooks covering Linux, DevOps, Cloud, and more

Browse Books →