Managing Linux services with systemctl
systemctl is systemd’s command-line interface for controlling units such as SSH, Nginx, firewalld and databases. Its boot and runtime controls are deliberately separate: enable and disable change future startup behaviour, while start and stop affect the service now.
For Australian administrators, that distinction prevents accidental outages during maintenance. RHEL, CentOS Stream and Fedora are common in local teams, while Ubuntu is also widespread, and each distribution may name or package the same daemon differently.
Boot intent and runtime state
A service can be running without being enabled, or enabled while currently stopped. This occurs because systemd records two related states: runtime activity and symbolic links to unit files under boot targets.
| Action | Effect now | Effect after boot | Typical purpose |
|---|---|---|---|
systemctl start sshd |
Starts the service | No automatic startup | Immediate access |
systemctl enable sshd |
No runtime change | Starts automatically | Persistent startup |
systemctl disable sshd |
Keeps it running | Prevents automatic startup | Retire from boot |
systemctl stop sshd |
Stops the service | No change | Planned maintenance |
systemctl enable --now sshd |
Starts the service | Starts automatically | Combined operation |
systemctl enable sshd creates the symbolic links needed to start sshd.service during boot. systemctl disable sshd removes those links. Neither command changes whether the daemon is running, so use enable --now or disable --now when both boot intent and runtime state should change together.
Vendor packages can apply presets, so systemctl preset sshd restores the distribution’s default enablement policy. Check systemctl is-enabled sshd and systemctl is-active sshd separately because they answer different operational questions.
Safe enable and disable workflows
Before changing a unit, inspect its identity and dependencies with systemctl cat nginx, systemctl status nginx, and systemctl list-dependencies nginx. Fedora and RHEL usually expose SSH as sshd.service, Debian and Ubuntu as ssh.service, and Nginx generally as nginx.service, but the installed unit should always be confirmed.
Use a short, reversible sequence: sudo systemctl enable --now nginx, verify it with systemctl is-enabled nginx && systemctl is-active nginx, and record the result in the change log. When retiring a service, sudo systemctl disable --now nginx stops it and removes its boot links. Do not use mask for routine retirement; masking deliberately prevents manual activation and requires a separate unmask operation to reverse.
Long interactive changes are safer in a terminal multiplexer. This Fedora tmux workflow demonstrates how tmux can preserve shells when an SSH connection drops or a package operation temporarily interrupts the terminal.
For per-account workloads, systemctl --user enable --now app.service operates on user units. Ensure the account can log in, or enable lingering with sudo loginctl enable-linger alice, especially on remote hosts and minimal containers.
Remote systems and session resilience
Changes made over SSH can be interrupted by a dropped connection. For isolated bastion-style access, a tested reverse SSH access setup can provide a controlled route back to an administration host, but key permissions, source restrictions and monitoring still need local review.
Avoid combining remote administration with unattended enablement until the required package, unit and configuration have been validated. ACSC guidance supports tightly controlled privileged access and auditable administrative accounts; any temporary SSH or sudo access should expire according to the organisation’s risk assessment.
Keep a rollback command available before modifying boot behaviour. Disabling a service that another unit depends upon can produce failures that appear only after reboot, particularly when updates replace the original unit or its supporting configuration.
Discoverability and fleet consistency
Large fleets need reliable unit names and evidence rather than memory. systemctl list-unit-files --type=service provides a searchable inventory, while systemctl show sshd -p UnitFileState -p ActiveState exposes the properties required for scripts. Keyboard-first administrators can apply the same search principle to unit discovery, using the interactive method discovery guide as an example of shortening the learning curve for unfamiliar interfaces.
Australian organisations often combine on-premise systems in Sydney and Melbourne with cloud capacity in Sydney, Melbourne, Brisbane and offshore regions. Local resellers and managed-service providers may standardise RHEL for supported enterprise workloads, Ubuntu for web platforms, or CentOS Stream and Fedora for development. Document the unit name and lifecycle owner for every service so procurement and technical teams share the same baseline.
Time settings deserve explicit verification because Australian sites may run on AEST, ACST, AWST or ACST, with daylight-saving transitions, while systemd journals commonly record UTC. Use timedatectl to check the host zone and synchronisation, and include timezone and enablement state in incident notes so an operator in Perth can interpret a log written in Sydney correctly.
A dependable operating routine
Before a scheduled change, identify the unit, current runtime state, boot target, dependencies and rollback command. Keep the evidence in the same runbook used for package and configuration changes.
- Check
is-activeandis-enabledbefore touching the unit. - Read
status,catand the relevant journal entries. - Use
enable --nowonly when startup and immediate activation are both required. - Use
disable --nowonly when stopping the current instance is intentional. - Prefer
presetwhen restoring packaged defaults rather than custom policy. - Record the command, operator, timestamp and verification output.
Afterwards, test the service from a separate session and confirm that the intended boot target contains the unit. If it must not start under any circumstances, evaluate mask and document how it will be lifted; masking is stronger than disabling and behaves differently from a vendor preset.
The dependable rule is to treat boot intent and runtime state as separate decisions, change the smallest scope required, and verify both after the change. That routine gives on-call engineers in Adelaide, Canberra and other Australian locations a clear, repeatable basis for keeping essential Linux services available without leaving stale startup links behind.