Useful Commands/Service Management: Difference between revisions
Jump to navigation
Jump to search
| Line 3: | Line 3: | ||
! Purpose || Command | ! Purpose || Command | ||
|- | |- | ||
| List | | List || | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
systemctl -t service | systemctl -t service | ||
| Line 9: | Line 9: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
|- | |- | ||
| Setup | | Setup || | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
sudo systemctl enable llama-swap | sudo systemctl enable llama-swap | ||
| Line 18: | Line 18: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
|- | |- | ||
| Monitor | | Monitor || | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
systemctl status llama-swap | systemctl status llama-swap | ||
| Line 24: | Line 24: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
|- | |- | ||
| Control | | Control || | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
systemctl start nginx | systemctl start nginx | ||
Revision as of 01:48, 10 September 2026
systemctl
| Purpose | Command |
|---|---|
| List |
systemctl -t service
systemctl list-units -t service
|
| Setup |
sudo systemctl enable llama-swap
sudo systemctl disable llama-swap
sudo rm -f /etc/systemd/system/llama-swap.service
sudo systemctl daemon-reload
|
| Monitor |
systemctl status llama-swap
systemctl status llama-swap.service
|
| Control |
systemctl start nginx
systemctl stop nginx
systemctl reload nginx
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 |