systemctl: Start, Stop and Enable Linux Services
Start, stop, enable, mask and troubleshoot Linux services with systemctl and journalctl: drop-in overrides, unit files and status codes, with examples.
Use systemctl start to run a service now, systemctl stop to stop it, and systemctl enable to start it at every boot. systemctl enable --now does both at once. Check the result with systemctl status and read the service's logs with journalctl -u. Run these as root or with sudo.
This is a working reference for managing services with systemd on RHEL, Rocky, AlmaLinux, Fedora, Ubuntu and Debian. If you are setting up a new server, start with our RHEL 10 first-time setup guide, then come back here. Command behaviour was checked against the systemd 262 man pages on freedesktop.org in November 2026.
Key takeaways
- Starting and enabling are separate.
startaffects the running system;enableaffects the next boot. enable --nowanddisable --nowcombine both steps.masklinks a unit to/dev/nullso nothing can start it, not even as a dependency. Use it when a service must stay off.- Never edit vendor unit files in
/usr/lib/systemd/system. Usesystemctl editto create a drop-in override, andsystemctl revertto undo it. - After changing unit files by hand, run
systemctl daemon-reload. It reloads configuration but does not restart services. - When a service fails, read
systemctl status, thenjournalctl -u name -b, then fix and runsystemctl reset-failedif restart limits were hit.
What systemctl controls
systemd is the init system and service manager on almost every mainstream Linux distribution. It manages units. A unit is described by a file, and the suffix says what kind it is: .service for daemons, .socket for socket activation, .timer for scheduled jobs, .target for groups of units such as multi-user.target, and .mount for file systems. systemctl is the command-line client that talks to systemd.
Unit files live in three main places, and the later ones win:
| Path | Who owns it | Should you edit it? |
|---|---|---|
/usr/lib/systemd/system/ (Debian and Ubuntu also use /lib/systemd/system/) | Packages | No. Package updates overwrite it. |
/run/systemd/system/ | Runtime, generated | No. Lost at reboot. |
/etc/systemd/system/ | Administrator | Yes. Overrides and your own units go here. |
If you are still getting used to where configuration lives, our guide to /etc, /home and /var explains the layout.
Start, stop, restart and reload
These commands change what is running right now. They do not change boot behaviour.
sudo systemctl start nginx # start the service
sudo systemctl stop nginx # stop it
sudo systemctl restart nginx # stop then start
sudo systemctl reload nginx # ask the daemon to re-read config without stopping
sudo systemctl reload-or-restart nginx
sudo systemctl try-restart nginx # restart only if it is already running
The .service suffix is optional; nginx and nginx.service mean the same thing.
reload vs restart
reload sends the service its reload action, usually a signal that makes it re-read configuration while keeping connections open. Not every service supports it. reload-or-restart reloads if the unit supports it and restarts otherwise, and it also starts the unit if it was stopped. try-restart does nothing if the service is not running, which is useful in scripts that should not bring up services an admin deliberately stopped.
For a web server or proxy in production, prefer reload after a config change so in-flight requests are not dropped. Test the configuration first with the daemon's own check (for example nginx -t).
Enable and disable at boot
sudo systemctl enable nginx # start at boot (does not start it now)
sudo systemctl enable --now nginx # start at boot and start now
sudo systemctl disable nginx # do not start at boot
sudo systemctl disable --now nginx # do not start at boot and stop now
enable reads the [Install] section of the unit and creates symlinks, usually under /etc/systemd/system/multi-user.target.wants/. That is why enabling prints lines like Created symlink .... disable removes those symlinks.
Enablement states you will see
| State | Meaning |
|---|---|
enabled | Symlinks exist; starts at boot |
disabled | Has an [Install] section but is not enabled |
static | No [Install] section; only starts when another unit needs it |
masked | Linked to /dev/null; cannot be started at all |
indirect | Enabled through another unit, such as a socket or timer |
A common surprise: some services are socket-activated. If cups.socket is enabled, disabling cups.service alone will not stop it from starting when something connects to the socket. Disable or mask the socket too.
Mask a service so nothing can start it
sudo systemctl mask --now bluetooth.service
sudo systemctl unmask bluetooth.service
Disabling only stops a service from starting at boot by itself. Another unit can still pull it in as a dependency, and a user can start it by hand. Masking points the unit file at /dev/null, so every start attempt fails. Use it for services that conflict with each other, or ones a hardening baseline says must stay off. Remember you masked it: a masked unit gives a clear error, but it is easy to forget months later.
Check service state
systemctl status sshd
systemctl is-active sshd # prints active / inactive / failed, exit 0 if active
systemctl is-enabled sshd # prints enabled / disabled / masked / static
systemctl is-failed sshd # exit 0 if the unit is in failed state
status shows whether the unit is loaded, its enablement, whether it is active and since when, the main PID, its control group with child processes, and the last few log lines. Those log lines are often enough to spot the problem.
The is-* commands are made for scripts and health checks because they set the exit code:
if ! systemctl is-active --quiet nginx; then
echo "nginx is down" >&2
exit 1
fi
List units
systemctl list-units --type=service # loaded services
systemctl list-units --type=service --state=running
systemctl list-units --failed # anything in failed state
systemctl list-unit-files --type=service # installed units and enablement
systemctl list-dependencies multi-user.target
systemctl list-timers # scheduled timer units
Run systemctl list-units --failed first when you log into a server you do not know. It is a quick health check.
To see the processes behind a service in more detail, our guide to monitoring processes with ps, top and htop pairs well with systemctl status.
Read service logs with journalctl
systemd captures stdout and stderr of every service in the journal. These are the queries used most in practice:
journalctl -u nginx # all logs for one unit
journalctl -u nginx -b # since the current boot
journalctl -u nginx -b -1 # from the previous boot
journalctl -u nginx -f # follow, like tail -f
journalctl -u nginx --since "1 hour ago"
journalctl -u nginx -p err # priority err and worse
journalctl -u nginx -n 50 --no-pager # last 50 lines, no pager
journalctl -xe # recent entries with explanations
Combine filters as needed. journalctl -u nginx -b -p warning answers "what went wrong with nginx since boot" in one line. On some distributions the journal is kept in memory only and is lost at reboot. Creating /var/log/journal or setting Storage=persistent in /etc/systemd/journald.conf keeps it across boots.
Change a service safely with drop-in overrides
Suppose you want a service to restart automatically if it crashes. Editing the packaged unit file works until the next package update overwrites it. A drop-in survives updates.
sudo systemctl edit myapp.service
This opens an editor on /etc/systemd/system/myapp.service.d/override.conf. Add only the settings you want to change:
[Service]
Restart=on-failure
RestartSec=5s
Save and exit. systemctl edit reloads the configuration for you. Restart the service to apply it:
sudo systemctl restart myapp
systemctl cat myapp # shows the main unit plus every drop-in, with file names
To undo all your overrides and go back to the vendor file, run sudo systemctl revert myapp. If you really need to replace the whole unit, systemctl edit --full copies it to /etc/systemd/system/ for editing.
Clearing list-type settings
Some directives, such as ExecStart=, add to a list. To replace the command in a drop-in, first set it empty, then set the new value:
[Service]
ExecStart=
ExecStart=/usr/local/bin/myapp --config /etc/myapp/prod.yaml
Without the empty line, systemd refuses to load a simple service with two ExecStart lines.
Write your own service unit
For an internal application, create /etc/systemd/system/myapp.service:
[Unit]
Description=My internal API
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
User=myapp
Group=myapp
WorkingDirectory=/opt/myapp
EnvironmentFile=-/etc/myapp/env
ExecStart=/opt/myapp/bin/server --port 8080
Restart=on-failure
RestartSec=5s
[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl enable --now myapp
systemctl status myapp
What the important lines do:
After=andWants=order the service after the network is up and pull that target in. Ordering and requirement are separate settings in systemd.Type=simplemeans the process started byExecStartis the main process. Other values in the systemd 262 docs areexec,forking,oneshot,dbus,notify,notify-reloadandidle. Useforkingonly for legacy daemons that background themselves.User=runs the service as an unprivileged account. Do not run application code as root.- The
-before theEnvironmentFilepath means "ignore if missing". Restart=on-failurerestarts after a non-zero exit, a crash signal, or a timeout. The allowed values areno(the default),on-success,on-failure,on-abnormal,on-watchdog,on-abortandalways.RestartSecdefaults to 100 ms, which is often too fast for a service waiting on a database.WantedBy=multi-user.targetis whatenableuses to decide where to create the symlink.
Troubleshooting a service that will not start
- Read the status.
systemctl status myappshows the exit code and last log lines.status=203/EXECusually means theExecStartpath is wrong or not executable.status=217/USERmeans the user inUser=does not exist. - Read the full log.
journalctl -u myapp -b --no-pager. - Check the unit file you think is loaded.
systemctl cat myapp. If you edited a file without runningdaemon-reload, systemd is still using the old copy, andstatuswarns about it. - Run the command by hand as the service user:
sudo -u myapp /opt/myapp/bin/server --port 8080. Missing environment variables and permission errors show up quickly this way. - Check SELinux on RHEL family systems. A binary in an unusual location may have the wrong context.
ausearch -m avc -ts recentshows denials. Our SELinux in RHEL 10 guide covers contexts and booleans. - Clear the failed state. If the service restarted too many times in a short window, systemd stops trying and reports a start-limit error. After fixing the cause, run
sudo systemctl reset-failed myappand start it again.
Common systemctl commands at a glance
| Task | Command |
|---|---|
| Start now | systemctl start NAME |
| Stop now | systemctl stop NAME |
| Restart | systemctl restart NAME |
| Reload config | systemctl reload NAME |
| Start at boot | systemctl enable NAME |
| Start at boot and now | systemctl enable --now NAME |
| Never start | systemctl mask NAME |
| Status | systemctl status NAME |
| Failed units | systemctl list-units --failed |
| Show unit and drop-ins | systemctl cat NAME |
| Override settings | systemctl edit NAME |
| Reload unit files | systemctl daemon-reload |
| Logs for this boot | journalctl -u NAME -b |
| Single property | systemctl show -p MainPID NAME |
| Per-user service | systemctl --user start NAME |
Timers vs cron
systemd timers can replace many cron jobs. A .timer unit triggers a matching .service unit, and you get journal logging, dependency ordering and resource controls for free. systemctl list-timers shows the last and next run. Cron is still fine for simple jobs. Our posts on automating tasks with crontab and cron limitations at scale help you decide.
Learn Linux service management hands-on
Managing services, boot targets and logs is part of the RHCSA exam objectives and of daily DevOps work. Our RHCSA training covers systemd, journald, SELinux and storage on RHEL in lab sessions, in the Kharadi, Pune classroom or live online across India. For broader admin skills, see the Linux administration course. To check your knowledge, try our Linux FAQs asked in DevOps interviews.
FAQ
What is the difference between systemctl start and systemctl enable?
start runs the service now but does not affect the next boot. enable creates the symlinks that start it at boot but does not start it now. Use enable --now to do both.
How do I stop a service from starting at boot?
Run sudo systemctl disable NAME. Add --now to also stop it immediately. If another unit or a socket can still start it, mask it with sudo systemctl mask NAME.
What does systemctl daemon-reload do?
It makes systemd re-read all unit files and rebuild its dependency tree. It does not restart any service. Run it after creating or editing unit files by hand, then restart the affected service.
What is the difference between disable and mask?
disable removes the boot-time symlinks, but the service can still be started manually or as a dependency. mask links the unit to /dev/null so no one and nothing can start it until you unmask it.
How do I see logs for one service?
Use journalctl -u NAME. Add -b for the current boot, -f to follow new lines, -p err to show only errors, or --since "1 hour ago" to limit the time range.
How do I change a service setting without editing the vendor unit file?
Run sudo systemctl edit NAME and add only the changed lines under the right section. systemd saves them as a drop-in under /etc/systemd/system/NAME.service.d/ and keeps them across package updates.
Why does my service show status=203/EXEC?
systemd could not run the ExecStart command. The path is usually wrong, the file is not executable, or on RHEL the SELinux context blocks it. Check the path and permissions, then journalctl -u NAME.
Can regular users run systemd services?
Yes. systemctl --user manages a per-user service manager, with unit files under ~/.config/systemd/user/. These services run with the user's own permissions.
References
What's Your Reaction?
Like
0
Dislike
0
Love
0
Funny
0
Angry
0
Sad
0
Wow
0