service
行程與系統
用法
service <name> <start|stop|restart|status>這是 SysV 時代留下的一層薄殼;在 systemd 機器上它只是把命令轉給 systemctl,而且認得的動詞更少。
常用選項
| 選項 | 含義 |
|---|---|
| start / stop / restart | The three verbs that work everywhere. |
| status | Ask the service how it is doing. |
| --status-all | List every init script and its state (Debian/Ubuntu). |
範例
sudo service nginx restartRestart a service on a machine of any vintage.
service --status-allSee every service the old init system knows about.
看什麼在跑、什麼在吃機器。先弄清是什麼,再決定殺不殺。
怎麼看
- 方括號 [ ] 表示這部分可以不寫。
- 省略號 … 表示可以寫多個。
- 選項區分大小寫——有些命令裡 -r 和 -R 不是一回事。
常見問題
Q. service 是做什麼的?
這是 SysV 時代留下的一層薄殼;在 systemd 機器上它只是把命令轉給 systemctl,而且認得的動詞更少。
Q. 怎麼寫?
service <name> <start|stop|restart|status> —— 方括號表示可以省略的部分。
Q. 值得記的選項有幾個?
這裡列了 3 個,完整列表在 man service。這條命令屬於行程與系統。
相關命令
man 手冊: man service