小学算数1201808 views
中学社会669349 views
小学理科720598 views
世界の国565616 views
ヒストリア292421 views
高校日本史190729 views
いろは3016946 views
中学数学624303 views
英語615205 views
Computer368957 views
Help
Tools

English

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 のサービスは自動起動が設定されているサービス。