Irohabook
0
1438

CentOSのsystemctlコマンド一覧

app というサービスを起動するときは

systemctl start app

または

systemctl start app.service

とする。.service はあってもなくてもいい。例えば nginx の場合は

systemctl start nginx

で起動する。

特定のサービスにおけるコマンド一覧

以下の表にある app という単語は、使いたいサービス名に変換すること。

コマンド名 コマンド
起動 systemctl start app
停止 systemctl stop app
再起動 systemctl restart app
リロード systemctl reload app
自動起動を設定する systemctl enable app
自動起動を無効にする systemctl disable app
ステータスの表示 systemctl status app
アクティブかどうかの確認 systemctl is-active app
自動起動の設定確認 systemctl is-enabled app

サービスを横断的にチェックするコマンド一覧

特定のサービスでなく、設定しているすべてのサービスをチェックするときは次のコマンドを使う。

コマンド名 コマンド
サービスの一覧 systemctl list-units --all
アクティブなサービスの一覧 systemctl list-unit-files --type=service
サービス設定のリロード systemctl daemon-reload

サービスは .service というファイルで設定する。ファイルの中身を変更したら systemctl daemon-reload をしないと反映しない。

表示例

systemctl list-units --all はすべてのサービスを表示する。

  crond.service                                                     loaded    active   running   Command Scheduler
  dbus.service                                                      loaded    active   running   D-Bus System Message Bus
● display-manager.service                                           not-found inactive dead      display-manager.service

inactive も表示されている。active なサービスのみを表示するときは systemctl list-unit-files --type=service を使う。サービス名の隣に STATE がある。

cpupower.service                              disabled
crond.service                                 enabled 
dbus-org.fedoraproject.FirewallD1.service     enabled 
dbus-org.freedesktop.hostname1.service        static

enabled のサービスは自動起動が設定されているサービス。

次の記事

Linuxコマンド