手当たり次第に書くんだ

飽きっぽいのは本能

LPIC systemctl コマンド – systemd unit を操作する

LPIC 学習ノートへ戻る

この記事では、LPIC 学習向けに systemctl コマンドを整理します。systemctl は systemd の unit を操作する中心的なコマンドで、サービスの起動、停止、有効化、状態確認に使います。

systemctl の基本操作

操作コマンド
状態確認systemctl status nginx
起動systemctl start nginx
停止systemctl stop nginx
再起動systemctl restart nginx
自動起動有効化systemctl enable nginx
自動起動無効化systemctl disable nginx

サービスを操作する

systemctl status sshd
systemctl start sshd
systemctl restart sshd
systemctl enable sshd
systemctl is-enabled sshd

unit 一覧を確認する

systemctl list-units
systemctl list-unit-files
systemctl --failed

target を確認する

systemd では、従来のランレベルに相当するものとして target を使います。

systemctl get-default
systemctl set-default multi-user.target
systemctl isolate rescue.target

注意点

  • start は今すぐ起動、enable は次回起動時の自動起動設定です。
  • 設定ファイルを変更した後は daemon-reload が必要な場合があります。
  • 失敗した unit は systemctl --failedjournalctl で確認します。

まとめ

systemctl は、systemd 環境でサービスと unit を管理する基本コマンドです。LPIC では、startenable の違い、unit 一覧、failed unit、target の扱いを押さえると実用的です。

関連する記事

参考書籍

参考
書籍
参考書籍
ストーリーで覚える Linux CLI 入門

Linux のコマンドライン操作を基礎から確認したい場合の参考書籍です。価格や在庫はリンク先で確認してください。

Amazon で見る

このリンクは Amazon アソシエイトリンクです。

LPIC systemctl コマンド – systemd unit を操作する

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

日本語が含まれない投稿は無視されますのでご注意ください。(スパム対策)

トップへ戻る