systemd チートシート
systemdコマンドのクイックリファレンス。サービス管理、ユニットファイル、journalctl、タイマー、ターゲット、systemd-analyze、ソケットを網羅
68 件のコマンド
systemctl startサービスを起動
sudo systemctl start nginxsystemctl stopサービスを停止
sudo systemctl stop nginxsystemctl restartサービスを再起動
sudo systemctl restart nginxsystemctl reloadサービスの設定を再読み込み
sudo systemctl reload nginxsystemctl statusサービスの状態を表示
systemctl status nginxsystemctl enableサービスの自動起動を有効化
sudo systemctl enable nginxsystemctl disableサービスの自動起動を無効化
sudo systemctl disable nginxsystemctl enable --now自動起動を有効化して即起動
sudo systemctl enable --now nginxsystemctl is-activeサービスがアクティブかチェック
systemctl is-active nginxsystemctl is-enabledサービスの自動起動が有効かチェック
systemctl is-enabled nginxsystemctl is-failedサービスが失敗状態かチェック
systemctl is-failed nginxsystemctl maskサービスをマスク(起動不可に)
sudo systemctl mask nginxsystemctl unmaskサービスのマスクを解除
sudo systemctl unmask nginxsystemctl list-unitsアクティブなユニット一覧を表示
systemctl list-unitssystemctl list-units --type=serviceサービスユニット一覧を表示
systemctl list-units --type=servicesystemctl list-units --failed失敗したユニット一覧を表示
systemctl list-units --failedsystemctl list-unit-files全ユニットファイル一覧を表示
systemctl list-unit-filessystemctl catユニットファイルの内容を表示
systemctl cat nginx.servicesystemctl showユニットのプロパティを表示
systemctl show nginx -p MainPIDsystemctl editユニットのオーバーライドを編集
sudo systemctl edit nginxsystemctl edit --fullユニットファイル全体を編集
sudo systemctl edit --full nginxsystemctl daemon-reloadユニットファイルの変更を反映
sudo systemctl daemon-reloadsystemctl list-dependenciesユニットの依存関係を表示
systemctl list-dependencies nginxsystemctl reset-failed失敗状態のユニットをリセット
sudo systemctl reset-failedjournalctl全ジャーナルログを表示
journalctljournalctl -u特定ユニットのログを表示
journalctl -u nginxjournalctl -fログをリアルタイムで表示
journalctl -fjournalctl -u -f特定ユニットのログをリアルタイム表示
journalctl -u nginx -fjournalctl --since指定日時以降のログを表示
journalctl --since '2024-01-01 00:00:00'journalctl --since --until指定期間のログを表示
journalctl --since '1 hour ago' --until 'now'journalctl -p優先度でログをフィルタリング
journalctl -p errjournalctl -b現在のブート以降のログを表示
journalctl -bjournalctl -b -1前回のブートのログを表示
journalctl -b -1journalctl --disk-usageジャーナルのディスク使用量を表示
journalctl --disk-usagejournalctl --vacuum-sizeジャーナルのサイズを制限して古いログを削除
sudo journalctl --vacuum-size=500Mjournalctl --vacuum-time指定期間より古いログを削除
sudo journalctl --vacuum-time=30djournalctl -o jsonログをJSON形式で出力
journalctl -u nginx -o json-prettysystemctl list-timersアクティブなタイマー一覧を表示
systemctl list-timerssystemctl list-timers --all全タイマー一覧を表示
systemctl list-timers --allsystemctl start timerタイマーを起動
sudo systemctl start backup.timersystemctl stop timerタイマーを停止
sudo systemctl stop backup.timersystemctl enable timerタイマーの自動起動を有効化
sudo systemctl enable backup.timersystemd-run --on-calendar一時的なタイマーを作成(カレンダー)
systemd-run --on-calendar='*-*-* 02:00:00' /usr/bin/backup.shsystemd-run --on-active指定時間後に一度だけ実行
systemd-run --on-active=30m /usr/bin/cleanup.shsystemctl get-defaultデフォルトのターゲットを表示
systemctl get-defaultsystemctl set-defaultデフォルトのターゲットを設定
sudo systemctl set-default multi-user.targetsystemctl isolate指定ターゲットに切り替え
sudo systemctl isolate graphical.targetsystemctl rescueレスキューモードに切り替え
sudo systemctl rescuesystemctl emergency緊急モードに切り替え
sudo systemctl emergencysystemctl poweroffシステムをシャットダウン
sudo systemctl poweroffsystemctl rebootシステムを再起動
sudo systemctl rebootsystemctl suspendシステムをサスペンド
sudo systemctl suspendsystemd-analyze起動時間を分析
systemd-analyzesystemd-analyze blameユニットごとの起動時間を表示
systemd-analyze blamesystemd-analyze critical-chain起動のクリティカルチェーンを表示
systemd-analyze critical-chainsystemd-analyze plot起動時間のSVGグラフを生成
systemd-analyze plot > boot.svgsystemd-analyze verifyユニットファイルの構文を検証
systemd-analyze verify myservice.servicesystemd-analyze dot依存関係のDOTグラフを生成
systemd-analyze dot | dot -Tsvg > deps.svgsystemd-analyze securityサービスのセキュリティ設定を分析
systemd-analyze security nginx.servicesystemd-cglsコントロールグループ階層を表示
systemd-cglssystemd-cgtopコントロールグループのリソース使用量を表示
systemd-cgtopsystemctl list-socketsソケットユニット一覧を表示
systemctl list-socketssystemctl start socketソケットユニットを起動
sudo systemctl start myapp.socketloginctl list-sessionsログインセッション一覧を表示
loginctl list-sessionsloginctl list-usersログイン中のユーザー一覧を表示
loginctl list-usershostnamectlホスト名の表示・設定
hostnamectl set-hostname myservertimedatectl日時・タイムゾーンの表示・設定
timedatectl set-timezone Asia/Tokyolocalectlロケール・キーボード設定の表示・変更
localectl set-locale LANG=en_US.UTF-8