Useful Commands/Service Management: Difference between revisions

From Fundamental Ramen
Jump to navigation Jump to search
Line 1: Line 1:
== systemctl ==
== systemctl ==
{| class="wikitable"
{| class="wikitable"
! 情境 || Command
! Purpose || Command  
|-
|-
| List services ||
| List services ||
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
systemctl -t service           # 省略式
systemctl -t service
systemctl list-units -t service # 完整式
</syntaxhighlight>
|-
| Setup a service ||
<syntaxhighlight lang="bash">
systemctl reload nginx
systemctl disable mysql.service
systemctl reload systemd-networkd
</syntaxhighlight>
|-
| Monitor a service ||
<syntaxhighlight lang="bash">
systemctl status nginx
</syntaxhighlight>
</syntaxhighlight>
|-
|-
| Control services ||
| Control services ||
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
systemctl status nginx
systemctl start  nginx
systemctl start  nginx
systemctl stop  nginx
systemctl stop  nginx
systemctl reload nginx
systemctl disable mysql.service
systemctl reload systemd-networkd
</syntaxhighlight>
</syntaxhighlight>
|}
|}

Revision as of 01:33, 10 September 2026

systemctl

Purpose Command
List services
systemctl -t service
Setup a service
systemctl reload nginx
systemctl disable mysql.service
systemctl reload systemd-networkd
Monitor a service
systemctl status nginx
Control services
systemctl start  nginx
systemctl stop   nginx

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