Linuxコマンド一覧

systemctlコマンド|サービスを起動・停止・確認する

__ __ _ _____
\ \ / /__| |_|_ _|__ _ __ _ __ ___
\ \ /\ / / _ \ '_ \| |/ _ \ '__| '_ ` _ \
\ V V / __/ |_) | | __/ | | | | | |
\_/\_/ \___|_.__/|_|\___|_| |_| |_| |_
 
systemctl を試すためのサンドボックスです。実機のファイルには影響しません。
user@webterm:~/project$
 

systemctl は Linux のサービスを操作するコマンドです。`status` の読み方、`start` と `enable` の違い、動いているサービスの一覧の見方を、ブラウザ上のターミナルで打ちながら確認できます。

最終更新: 2026-09-07

書式

systemctl サブコマンド サービス名

サービス(常駐して動き続けるプログラム)を操作します。

まず打ってみる

まずは状態の確認からです。

$ systemctl status nginx
 nginx.service - A high performance web server and a reverse proxy server
   Loaded: loaded (/lib/systemd/system/nginx.service; disabled; vendor preset: enabled)
   Active: inactive (dead) since Mon 2026-03-23 08:00:00 UTC; 2h ago

読むのは2行です。

意味
Loaded設定が読み込まれているか。disabled次の起動では動かない
Activeいま動いているか。inactive (dead) は止まっている

いまは止まっていて、自動起動も無効、という状態です。

起動する

止まっているので起動します。 サービスの操作には管理者の権限が要ります。

$ systemctl restart nginx
Failed to restart nginx.service: Interactive authentication required.
See system logs and 'systemctl status nginx.service' for details.
$ sudo systemctl start nginx
$ systemctl status nginx
 nginx.service - A high performance web server and a reverse proxy server
   Loaded: loaded (/lib/systemd/system/nginx.service; disabled; vendor preset: enabled)
   Active: active (running) since Mon 2026-03-23 08:00:00 UTC; 2h ago
   Main PID: 1001 (nginx)
   Tasks: 2 (limit: 4915)
   Memory: 2.3M
   CGroup: /system.slice/nginx.service
           └─1001 /usr/sbin/nginx

active (running) になり、プロセス番号(Main PID)も出ました。 状態だけを知りたいときは is-active のほうが短く済みます。

$ systemctl is-active nginx
active

いますぐ動かす/次の起動から動かす

ここが systemctl でいちばん混乱するところです。 start で動かしても、自動起動は無効のままです。

$ systemctl is-enabled nginx
disabled

サーバーを再起動しても動いていてほしいなら、enable が要ります。

$ sudo systemctl enable nginx
Created symlink /etc/systemd/system/multi-user.target.wants/nginx.service /lib/systemd/system/nginx.service.
$ systemctl is-enabled nginx
enabled
サブコマンドいま次の起動から
start動かす変わらない
stop止める変わらない
enable変わらない動かす
disable変わらない動かさない

「動かしたのに再起動したら消えた」は、enable を忘れたときの症状です。

動いているものを一覧する

$ systemctl list-units --type=service
UNIT                                LOAD   ACTIVE   SUB     DESCRIPTION
nginx.service                       loaded active   running A high performance web server and a reverse proxy server
ssh.service                         loaded active   running OpenBSD Secure Shell server
cron.service                        loaded active   running Regular background program processing daemon
networking.service                  loaded active   running Raise network interfaces
systemd-resolved.service            loaded active   running Network Name Resolution

LOAD   = Reflects whether the unit definition was properly loaded.
ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
SUB    = The low-level unit activation state, values depend on unit type.

5 loaded units listed. Pass --all to see loaded but inactive units, too.

既定では動いているものだけが出ます。 止まっているものも含めて見たいときは --all を付けます。

止める

$ sudo systemctl stop nginx
$ systemctl is-active nginx
inactive

実務での使いどころ

systemctl は、動いているはずのものが動いていないときに最初に打つコマンドです。

場面打ち方
動いているか確かめるsystemctl status nginx
設定を変えたので反映するsudo systemctl restart nginx
接続を切らずに設定を読み直すsudo systemctl reload nginx
再起動後も動くようにするsudo systemctl enable nginx
失敗した理由を読むjournalctl -u nginx

status で状態を見て、journalctl で理由を読む。 この2つを組で覚えると、サーバーの障害対応はだいたい進みます。

つまずきやすいところ

startenable は別物です。 start だけだと、サーバーを再起動した瞬間に止まったままになります。 両方必要なときは sudo systemctl enable --now nginx と書けます。

サービス名は .service を省略できます。 nginxnginx.service は同じ意味です。 存在しない名前を渡すと、そう言われます。

$ systemctl status nosuchservice
Unit nosuchservice.service could not be found.

status は要約です。 起動に失敗した理由まではここに出ません。 journalctl -u nginx でログ本体を読んでください。

手を動かして覚える

webterm.appこのサイト

learn.webterm.app別のサイト

>_WEBTERM LEARN

WebTerm Learn|1つのコマンドから、使える状態へ

コマンドは単体で覚えるより、実際の作業の流れの中で使うほうが身につきます。順番に積み上げていくコースがあります。

コースを見る

関連するコマンド

journalctl / sudo / ps / kill

よくある質問

start と enable はどう違いますか?
`start` は**いますぐ動かす**、`enable` は**次の起動から自動で動かす**です。両方したいなら `sudo systemctl enable --now nginx`、または start と enable を続けて実行します。
Interactive authentication required と出ます。
サービスの起動・停止には管理者の権限が要るという意味です。`sudo` を付けて実行してください。状態を見るだけの `status` や `is-active` には要りません。
restart と reload の違いは何ですか?
`restart` はプロセスを終了して起動し直します。`reload` は動かしたまま設定を読み直させます。接続を切りたくないときは reload が向いていますが、対応していないサービスもあります。
動いているサービスの一覧はどう見ますか?
`systemctl list-units --type=service` です。既定では動いているものだけが出ます。止まっているものも見たいときは `--all` を付けます。
エラーの詳細はどこで見られますか?
`journalctl -u <サービス名>` です。status は要約しか出さないので、起動に失敗した理由はログ側で読みます。