Useful Commands/Service Management: Difference between revisions

From Fundamental Ramen
Jump to navigation Jump to search
Line 33: Line 33:
|}
|}


== Run Level 說明 ==
== Run Level ==
 
{| class="wikitable"
{| class="wikitable"
! runlevel || 英文說明 || 中文說明
! Run Level || Description
|-
|-
| 0 || halt || 系統關機
| 0 || halt
|-
|-
| 1 || single user mode || 單人模式,用在系統出問題時的維護
| 1 || single user mode
|-
|-
| 2 || Multi-user, without NFS || 類似 runlevel 3,但無 NFS 服務
| 2 || Multi-user, without NFS
|-
|-
| 3 || Full multi-user mode || 完整含有網路功能的純文字模式
| 3 || Full multi-user mode
|-
|-
| 4 || unused || 保留
| 4 || unused
|-
|-
| 5 || X11 || 類似 runlevel 3,有使用 X Window
| 5 || X11
|-
|-
| 6 || reboot || 重新開機
| 6 || reboot
|}
|}

Revision as of 10:11, 7 September 2026

systemctl

情境 Command
List services
systemctl -t service            # 省略式
systemctl list-units -t service # 完整式
Control services
systemctl status nginx
systemctl start  nginx
systemctl stop   nginx
systemctl reload nginx
systemctl disable mysql.service
systemctl reload systemd-networkd

Linux 傳統

情境 指令
管理系統服務
sudo service start/stop/reload/restart {服務名稱}
顯示服務狀態
service --status-all
顯示服務 (啟動/關閉) 時機 (runlevel 0~6)
chkconfig --list
設定服務在開機後自動啟動
sudo chkconfig --level 2345 {服務名稱} on

Run Level

Run Level Description
0 halt
1 single user mode
2 Multi-user, without NFS
3 Full multi-user mode
4 unused
5 X11
6 reboot