C Shell Wiki
Posts (Latest 10 updated) :
Read all
Contents:
  1. [台灣] C Shell (csh) systemctl 使用法: 管理系統服務
    1. Overview
    2. Usage
    3. Common Options
    4. Common Examples
    5. Tips

[台灣] C Shell (csh) systemctl 使用法: 管理系統服務

Overview

systemctl 是一個用於控制和管理系統服務的命令,特別是在使用 systemd 的 Linux 發行版中。它可以啟動、停止、重啟服務,並檢查服務的狀態。

Usage

基本語法如下:

systemctl [options] [arguments]

Common Options

  • start: 啟動指定的服務。
  • stop: 停止指定的服務。
  • restart: 重啟指定的服務。
  • status: 顯示指定服務的當前狀態。
  • enable: 設定服務在系統啟動時自動啟動。
  • disable: 禁用服務在系統啟動時自動啟動。

Common Examples

以下是一些常見的 systemctl 使用範例:

  1. 啟動服務:
    systemctl start nginx
    
  2. 停止服務:
    systemctl stop nginx
    
  3. 重啟服務:
    systemctl restart nginx
    
  4. 檢查服務狀態:
    systemctl status nginx
    
  5. 設定服務自動啟動:
    systemctl enable nginx
    
  6. 禁用服務自動啟動:
    systemctl disable nginx
    

Tips

  • 確保以管理員權限執行 systemctl 命令,以避免權限問題。
  • 使用 status 選項可以快速檢查服務的運行狀態和日誌,幫助排除故障。
  • 定期檢查服務的狀態,確保系統的穩定性和安全性。