systemctl is systemd's tool for controlling Linux services, and over SSH it works exactly as on a local console. systemctl status shows state and recent logs, and restart stops and starts a service. enable --now starts it and enables it at boot, daemon-reload reloads edited unit files, and is-active returns a script-friendly state.
Core systemctl commands for managing a service over SSH
sudo systemctl start nginx starts the service and sudo systemctl stop nginx stops it. Queries such as status, is-active and is-enabled run without sudo, although an unprivileged user may not see the log lines. These commands cover almost all day-to-day work with a unit:
systemctl status nginx
sudo systemctl start nginx
sudo systemctl stop nginx
sudo systemctl restart nginx
sudo systemctl reload nginx
sudo systemctl enable --now nginx
sudo systemctl disable --now nginx
sudo systemctl daemon-reload
systemctl is-active nginx
systemctl is-enabled nginx
systemctl list-units --type=service --state=failedYou can omit the .service suffix from the unit name. Check the name of the SSH server itself, though: on Debian and Ubuntu the unit is usually called ssh, while other distributions use sshd. Every subcommand and option is documented in the systemctl manual page.
systemctl status: reading the state of a remote service
systemctl status nginx packs what you need for a diagnosis into a few lines:
- Loaded: the unit file path and whether it is
enabledordisabledat boot. - Active:
active (running),inactive (dead)orfailed, plus when it last changed. - Main PID and the process tree: which processes belong to the service.
- Recent journal lines: when a service fails to start, the error is usually here.
When the output is longer than the screen, status opens a pager that you leave with q. The --no-pager option skips the pager and -l (or --full) stops lines being truncated. If those lines are not enough, journalctl -u nginx -n 50 --no-pager gives more context. journalctl -u nginx -f follows the log live until you press Ctrl+C. Filters by time and priority are in the journalctl manual page.
systemctl restart, reload and enable --now: when to use each
- restart stops the service and starts it again, dropping any connections the process handles.
- reload asks the service to reread its configuration without stopping. It only works if the unit defines how; otherwise it returns an error.
- reload-or-restart reloads when the unit supports it and restarts when it does not.
- enable --now enables the service at boot and starts it immediately. Plain
enablestarts nothing until the next boot. - disable --now does the opposite: it removes the service from boot and stops it.
Before restarting the SSH server you are connected through, validate its configuration with sudo sshd -t. It prints any syntax error and exits with a non-zero code. Keep a second session open until you have confirmed you can log in again on TCP port 22 or whichever port you use.
systemctl daemon-reload after editing a .service file
sudo systemctl daemon-reload makes systemd reread its unit files. Without it, changes to a .service file are not applied, and status warns that the unit changed on disk. The usual sequence looks like this:
sudo nano /etc/systemd/system/myapp.service
sudo systemctl daemon-reload
sudo systemctl restart myapp
systemctl status myapp --no-pager -ldaemon-reload restarts no services; it only reloads the manager's configuration. The restart that follows is what makes the process run with the new definition.
systemctl is-active in scripts and quick checks
systemctl is-active prints the unit state (active, inactive, failed…) and exits with code 0 only when the unit is active. That makes it usable directly in conditionals. With --quiet it prints nothing and only the exit code matters:
systemctl is-active --quiet nginx && echo 'nginx OK' || sudo systemctl restart nginx
systemctl is-failed --quiet myapp && journalctl -u myapp -n 20 --no-pageris-enabled follows the same logic for boot-time state. is-failed catches units that have crashed, which also show up in systemctl list-units --type=service --state=failed.
systemctl on a phone versus a desktop: what changes
systemctl behaves the same in any SSH client. On a phone, the differences come from key access and connection stability:
| systemctl task | Phone (iOS/Android) | Desktop |
|---|---|---|
Leaving the pager or journalctl -f | Needs Ctrl and Esc, which the system keyboard hides | Ctrl and Esc always on the physical keyboard |
| Scrolling long logs | PgUp/PgDn only if the client provides them | Physical PgUp/PgDn keys |
| Connection during a long restart | Switching wifi to mobile data drops SSH; Mosh keeps the session | Network usually stable |
Editing a .service file | Terminal editor, or SFTP to download and upload | Local or remote editor |
termi1, an SSH and Mosh mobile terminal, adds its own keyboard with Esc, Ctrl, Tab, arrows and an fn layer with PgUp/PgDn, Home and End. Mosh keeps the session alive when you move from wifi to mobile data, and tmux keeps whatever you left running. Built-in SFTP lets you check a .service file without leaving the session. The AI types the command at the prompt without pressing Enter, and «Review» mode never runs it. On connections tagged as production, Production Guard ensures nothing gets Enter automatically. It also holds anything that stops or changes something, such as systemctl stop, before it reaches the prompt. You can get termi1 on the App Store or on Google Play.
Frequently asked questions
What is the difference between systemctl restart and systemctl reload?
systemctl restart stops the service and starts it again, dropping the connections its process handles. systemctl reload only asks the service to reread its configuration without stopping. It works only when the unit defines a reload action; reload-or-restart picks the right one automatically.
When do I need to run systemctl daemon-reload?
You need to run systemctl daemon-reload after creating, editing or deleting a unit file, for example under /etc/systemd/system. It reloads systemd's configuration without restarting any service, so you still need a restart for the process to pick up the changes.
Does restarting the ssh service with systemctl drop my SSH session?
Restarting the ssh service with systemctl normally leaves open sessions running, because each connection has its own process. The risk lies with new connections: if the configuration has errors, the service will not come back. Validate first with sudo sshd -t and keep a second session open.
How do I check in a script whether a systemd service is active?
A script checks whether a systemd service is active with systemctl is-active --quiet name. The command exits with code 0 when the unit is active and with a different code otherwise, printing nothing. You can chain it with && or || or use it inside an if.