Language
日本語
English

Caution

JavaScript is disabled in your browser.
This site uses JavaScript for features such as search.
For the best experience, please enable JavaScript before browsing this site.

Linux & Mac & Bash Command Dictionary

  1. Home
  2. Linux & Mac & Bash Command Dictionary
  3. systemctl / service

systemctl / service

Since: systemctl All Linux
service All Linux

systemctl is the command for managing services (daemons) through systemd. It covers the entire service lifecycle — starting, stopping, restarting, and configuring automatic startup. The older service command (SysVinit) also works in systemd environments through a compatibility layer.

Syntax

Basic service operations use the following form. UNIT is the service name (e.g., nginx, sshd).

systemctl start UNIT
systemctl stop UNIT
systemctl restart UNIT
systemctl reload UNIT
systemctl status UNIT
systemctl enable UNIT
systemctl disable UNIT

To list units, use the following commands.

systemctl list-units [--type=service]
systemctl list-unit-files [--type=service]

After editing a unit file, the systemd configuration needs to be reloaded.

systemctl daemon-reload

Command List

CommandDescription
systemctl start UNITStarts the service immediately.
systemctl stop UNITStops the service immediately.
systemctl restart UNITStops and then starts the service.
systemctl reload UNITReloads the configuration file without restarting the process (only for services that support it).
systemctl status UNITShows the service state, PID, and recent log entries.
systemctl enable UNITConfigures the service to start automatically on OS boot (does not start it immediately).
systemctl disable UNITDisables automatic startup on OS boot (does not stop the service immediately).
systemctl is-active UNITChecks whether the service is running (outputs active or inactive).
systemctl is-enabled UNITChecks whether automatic startup is configured (outputs enabled or disabled).
systemctl list-unitsLists currently loaded units.
systemctl list-unit-filesLists all installed unit files and their auto-start state.
systemctl daemon-reloadTells systemd to reload unit files from disk.

Basic Service Management

Start capsule_corp_api.service and check its status.

sudo systemctl start capsule_corp_api
systemctl status capsule_corp_api
● capsule_corp_api.service - Capsule Corp API Server
     Loaded: loaded (/etc/systemd/system/capsule_corp_api.service; enabled; preset: disabled)
     Active: active (running) since Thu 2026-04-09 10:00:00 JST; 3s ago
   Main PID: 12345 (python3)

Stop and restart the service.

sudo systemctl stop capsule_corp_api
sudo systemctl restart capsule_corp_api

Enable automatic startup on OS boot. enable only configures the next boot — it does not start the service right away.

sudo systemctl enable capsule_corp_api
sudo systemctl start capsule_corp_api

Use enable --now to enable and start in a single step.

sudo systemctl enable --now capsule_corp_api

List services. list-units shows currently loaded units; list-unit-files shows all installed ones.

systemctl list-units --type=service
systemctl list-unit-files --type=service
UNIT FILE                    STATE    PRESET
capsule_corp_api.service     enabled  disabled
dragon_radar.service         disabled disabled
gravity_chamber.service      enabled  disabled

Unit File Locations

Unit files (.service files) are placed in the following directories.

PathPurpose
/etc/systemd/system/Unit files created or customized by the administrator. Loaded with the highest priority.
/usr/lib/systemd/system/Unit files installed by the package manager (yum/apt, etc.). Editing these files directly causes the changes to be overwritten on the next package update.
/run/systemd/system/Dynamically generated unit files at runtime. Removed on reboot.

To customize a package's unit file, place a file with the same name under /etc/systemd/system/, or use systemctl edit to create a drop-in file.

sudo systemctl edit dragon_radar

Creating a Custom Service

You can manage any process as a service by creating a unit file under /etc/systemd/system/. The file name must be service-name.service.

/etc/systemd/system/gravity_chamber.service
[Unit]
Description=Gravity Chamber Training Scheduler
After=network.target

[Service]
Type=simple
User=vegeta
ExecStart=/usr/local/bin/gravity_chamber_server --config /etc/gravity_chamber/config.yml
ExecReload=/bin/kill -HUP $MAINPID
Restart=on-failure
RestartSec=5

[Install]
WantedBy=multi-user.target

After creating the file, run daemon-reload before starting the service.

sudo systemctl daemon-reload
sudo systemctl enable --now gravity_chamber
systemctl status gravity_chamber
● gravity_chamber.service - Gravity Chamber Training Scheduler
     Loaded: loaded (/etc/systemd/system/gravity_chamber.service; enabled; preset: disabled)
     Active: active (running) since Thu 2026-04-09 10:05:00 JST; 2s ago

Key sections and settings are described below.

Section / KeyDescription
[Unit] DescriptionHuman-readable description shown by systemctl status.
[Unit] AfterUnits that must be started before this service (dependency ordering).
[Service] TypeProcess startup model: simple (foreground process), forking (daemonizes via fork), oneshot (runs once and exits), etc.
[Service] UserUser account to run the process as. Defaults to root if omitted.
[Service] ExecStartThe command to run. Must be an absolute path.
[Service] RestartRestart policy when the process exits (on-failure, always, etc.).
[Install] WantedBySpecifies which target pulls in this service when enable is run. Typically multi-user.target.

Viewing Logs with journalctl

systemd logs are accessed via journalctl. Use the -u option to filter by service.

journalctl -u gravity_chamber
Apr 09 10:05:00 server gravity_chamber_server[12345]: Starting Gravity Chamber...
Apr 09 10:05:01 server gravity_chamber_server[12345]: Gravity multiplier set to 450G

The -f option tails the log in real time (press Ctrl+C to exit).

journalctl -u gravity_chamber -f

Use --since and --until to narrow the time range.

journalctl -u capsule_corp_api --since "2026-04-09 09:00:00"
journalctl -u capsule_corp_api --since "1 hour ago"
journalctl -u capsule_corp_api --since today

To view logs from multiple services at once, repeat the -u option.

journalctl -u gravity_chamber -u dragon_radar --since today

Differences from the service Command

The service command is a compatibility layer from the SysVinit era. On systemd systems, running service internally forwards the call to systemctl.

service (SysVinit)systemctl (systemd)
service nginx startsystemctl start nginx
service nginx stopsystemctl stop nginx
service nginx restartsystemctl restart nginx
service nginx statussystemctl status nginx
chkconfig nginx onsystemctl enable nginx
chkconfig nginx offsystemctl disable nginx

service directly invokes SysV scripts under /etc/init.d/ and is a simple wrapper. It does not provide the advanced features that systemd offers, such as dependency management, centralized log collection, socket-based activation, and cgroup-based resource control.

Overview

The smallest unit in systemd is called a "unit." Types include .service (services), .socket (sockets), .timer (timers), and .mount (mount points). systemctl is the front-end for managing all of these unit types.

enable works by creating a symbolic link under a directory such as /etc/systemd/system/multi-user.target.wants/. disable simply removes that link — it has no effect on whether the service is currently running.

reload sends a signal to the process asking it to re-read its configuration file, without stopping or restarting the process. This only works for services that support it. For services that do not handle reload signals, use restart instead.

Common Mistakes

Common Mistake 1: Confusing enable with start

enable configures the service to start automatically at the next OS boot — it does not start the service right now. A common source of confusion is running enable after installation and wondering why the service is not running.

sudo systemctl enable dragon_radar
sudo systemctl status dragon_radar
○ dragon_radar.service - Dragon Radar Service
     Loaded: loaded (/etc/systemd/system/dragon_radar.service; enabled; preset: disabled)
     Active: inactive (dead)

The service shows enabled but Active: inactive. You also need start to run it now.

sudo systemctl enable dragon_radar
sudo systemctl start dragon_radar
systemctl status dragon_radar
● dragon_radar.service - Dragon Radar Service
     Loaded: loaded (/etc/systemd/system/dragon_radar.service; enabled; preset: disabled)
     Active: active (running) since Thu 2026-04-09 10:10:00 JST; 1s ago

Use enable --now to enable and start the service in a single command.

sudo systemctl enable --now dragon_radar

Common Mistake 2: Forgetting daemon-reload after editing a unit file

If you edit a unit file without running daemon-reload, systemd does not see the changes. Restarting the service will still use the old configuration.

sudo vi /etc/systemd/system/training_scheduler.service
sudo systemctl restart training_scheduler
Warning: The unit file, source configuration file or drop-ins of training_scheduler.service changed on disk. Run 'systemctl daemon-reload' to reload units.

The correct sequence is: edit → daemon-reload → restart.

sudo vi /etc/systemd/system/training_scheduler.service
sudo systemctl daemon-reload
sudo systemctl restart training_scheduler

When using systemctl edit UNIT, daemon-reload is run automatically, so no manual step is needed. Only files edited directly on disk require a manual daemon-reload.

If you find any errors or copyright issues, please .