systemctl status <service-name> ※サービスの稼働状況を表示 systemctl is-active <service-name> ※サービスが稼働中か表示
| 状態 | 説明 |
| loaded | プロセスが起動している状態 |
| active(running) | プロセスが実行中 |
| active(exited) | プロセスの起動が終了 |
| active(waiting) | イベントの発生を待機中 |
| inactive | 起動していない |
| enabled | 自動起動がON |
| disabled | 自動起動がOFF |
systemctl is-enabled <service-name> ※自動起動の設定を表示 systemctl enable <service-name> ※自動起動ON systemctl disable <service-name> ※自動起動OFF systemctl preset <service-name> ※自動起動ONまたはOFF(プリセットポリシーに従う)
ls -l /etc/systemd/system/multi-user.target.wants/ ※自動起動を有効にするとここにサービスのシンボリックリンクが作成される
systemctl start <service-name> ※起動 systemctl stop <service-name> ※停止 systemctl restart <service-name> ※再起動 systemctl reload <service-name> ※サービスの設定を再読み込み
systemctl list-dependencies ※Unitの依存関係を表示 systemctl list-dependencies <service-name> ※Unitの依存関係を表示 systemctl list-units ※起動している全てのUnitの状態を表示 systemctl list-unit-files ※全てのUnitを表示 systemctl list-unit-files -t service ※サービスの一覧を表示 systemctl list-unit-files -t service --state=enabled ※サービスの一覧を表示(自動起動が有効のみ)
systemctl mask <service-name> ※マスク有効 systemctl unmask <service-name> ※マスク解除
systemctl daemon-reload
systemctl poweroff ※システムを停止 systemctl reboot ※システムを再起動
systemctl get-default ※デフォルトで設定されているターゲットを表示 systemctl set-default <target-name> ※デフォルトのターゲットの設定を変更
systemctl isolate poweroff.target ※システムを停止する systemctl isolate reboot.target ※システムを再起動する systemctl isolate rescue.target ※シングルユーザーモードに移行する systemctl isolate emergency.target ※緊急モードに移行する
systemctl get-default
systemctl set-default <target-name>
systemctl isolate rescue.target ※シングルユーザーモード systemctl isolate multi-user.target ※マルチユーザーモード systemctl isolate emergency.target ※緊急モード
| オプション名 | 説明 |
| Description | ユニットの説明 |
| Documentation | ユニットのドキュメント |
| After | 順序関係:指定されたユニットがアクティブになったら開始する |
| Before | 順序関係:指定されたユニットより先にアクティブになる必要がある |
| Requires | 依存関係:指定したユニットも起動する |
| Wants | 依存関係:指定したユニットも起動する ※Requiresより依存関係が弱い |
| Conflicts | 依存関係 ※Requiresと反対 |
| オプション名 | 説明 |
| Type | 起動タイプ(simple[default], forking, oneshot, dbus, notify) |
| ExecStart | ユニットの開始時に実行するコマンド |
| ExecStartPre | |
| ExecStartPost | |
| ExecStop | ユニットの停止時に実行するコマンド |
| ExecReload | 0 |
| Restart | ユニットの再起動の設定 (no[default], always, on-success, on-failure, on-abnormal, on-abort, on-watchdog) ※killやタイムアウトで終了した場合に再起動する(stopやrestartの操作で終了した場合は再起動しない) |
| RestartSec | 再起動する時の待機時間(単位:秒) |
| User | サービスを実行するユーザー |
| Group | サービスを実行するグループ |
| Environment | サービスの環境設定 |
| WorkingDirectory | サービスを実行する際の作業ディレクトリ |
| StandardOutput | 0 |
| StandardError | 0 |
| SuccessExitStatus | 指定したステータスを正常終了として扱う |
| KillMode | 0 |
| ProtectSystem | 0 |
| ProtectHome | 0 |
| NoNewPrivileges | 0 |
| PrivateTmp | 0 |
| ReadOnlyPaths | 0 |
| ReadWritePaths | 0 |
| オプション名 | 説明 |
| WantedBy | 依存関係の設定(記述されているユニットから依存されていることを表す) |
| RequiredBy | 0 |
| Alias | 0 |
| Also | 0 |
| DefaultInstance | 0 |
ls -l /etc/systemd/system/default.target →default.targetのリンク先で確認する →multi-user.target であればマルチユーザ
dnf install ntsysv
ntsysv