LoginSignup
1
0

systemctlメモ

Posted at

systemctlは、systemdを使用するLinuxディストリビューションでサービスやユニットの管理を行うためのコマンドです。systemdは、サービスの起動と停止、プロセスの管理、システムのログ記録などを行うシステムおよびサービスマネージャです。

基本的な使い方

サービスの管理

  1. サービスの開始

    systemctl start <service_name>
    

    例:

    systemctl start httpd
    
  2. サービスの停止

    systemctl stop <service_name>
    

    例:

    systemctl stop httpd
    
  3. サービスの再起動

    systemctl restart <service_name>
    

    例:

    systemctl restart httpd
    
  4. サービスのリロード(設定ファイルの再読み込み):

    systemctl reload <service_name>
    

    例:

    systemctl reload httpd
    
  5. サービスの有効化(ブート時に自動起動):

    systemctl enable <service_name>
    

    例:

    systemctl enable httpd
    
  6. サービスの無効化(ブート時の自動起動を無効化):

    systemctl disable <service_name>
    

    例:

    systemctl disable httpd
    
  7. サービスの状態確認

    systemctl status <service_name>
    

    例:

    systemctl status httpd
    

システム管理

  1. システムの再起動

    systemctl reboot
    
  2. システムのシャットダウン

    systemctl poweroff
    
  3. システムの休止

    systemctl hibernate
    
  4. システムのサスペンド

    systemctl suspend
    

その他のユニット管理

  1. ユニットの一覧表示

    systemctl list-units
    
  2. 全ユニットの一覧表示(アクティブと非アクティブの両方):

    systemctl list-units --all
    
  3. ユニットファイルの一覧表示

    systemctl list-unit-files
    
  4. 依存関係の確認

    systemctl list-dependencies <unit_name>
    

ユニットファイル

ユニットファイルは、systemdによって管理されるサービス、スワップ、マウントポイント、デバイスなどを定義するテキストファイルです。これらは通常、以下のディレクトリに配置されます:

  • /etc/systemd/system/
  • /lib/systemd/system/
  • /usr/lib/systemd/system/

Apache HTTPサーバーを管理する場合:

  1. サービスの開始:

    systemctl start httpd
    
  2. サービスの状態確認:

    systemctl status httpd
    
  3. サービスの自動起動を有効化:

    systemctl enable httpd
    
  4. サービスの自動起動を無効化:

    systemctl disable httpd
    

これで、systemctlコマンドの基本的な使い方と主なオプションについての説明を終わります。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0