Linux Tips: Mastering systemctl — Control Services & Boot Targets Like a Pro

A practical cheat-sheet for managing services, targets, and power states on systemd-based Linux distributions.



Why systemctl?

systemctl is the main command to manage systemd units (services, sockets, timers, targets, and more). With it, you can start/stop services, set what runs at boot, switch boot targets, and even manage power states.

Essential Service Commands

systemctl start unit.service

Start a service.

systemctl stop unit.service

Stop a running service.

systemctl restart unit.service

Restart the service.

systemctl status unit.service

Show active state and recent logs.

systemctl is-active unit.service

Is it running? Returns active or inactive.

systemctl enable unit.service

Start automatically at boot.

systemctl disable unit.service

Do not start at boot.

systemctl is-enabled unit.service

Check if enabled (0 = yes, 1 = no).

Inspect & Discover Services

systemctl list-unit-files --type=service

List available services on the system.

systemctl list-units --type=service

Show currently active services.

Boot Targets (Runlevels, the systemd way)

Switch the current session or set the default boot target:

systemctl isolate multi-user.target

Switch to multi-user (non-graphical, like runlevel 3).

systemctl set-default multi-user.target

Make multi-user the default boot target.

systemctl get-default

Show the current default target.

Quick map:
Classic Runlevelsystemd TargetDescription
3multi-user.targetNon-graphical, multi-user (servers/CLI)
5graphical.targetGraphical login (desktop)
1rescue.targetSingle-user rescue mode

Power Management

systemctl suspend

Low-power suspend.

systemctl hibernate

Save RAM to disk, power off.

Pro Tips

  • Most commands require sudo (or root).
  • Use systemctl status <unit> to see logs; for deeper logs, try journalctl -u <unit>.
  • Unit names often end in .service, but systemd manages many types (timers, sockets, targets, etc.).

Got a favorite systemctl trick? Share it in the comments!

Comments

Post a Comment