考点精讲
记忆技巧
「start 启、enable 开机、status 看」;enable 是「开机自启」而非「立即启动」。
「start 管当下、enable 管开机、restart 重启、disable 取消自启」。
systemctl list-units 列出单元,加 --all 可看未激活单元。
「start 管当下、enable 管开机、restart 重启、disable 取消自启」。
systemctl list-units 列出单元,加 --all 可看未激活单元。
常见误区
真题思路
- 【示例】 让某服务开机自动启动,应使用哪条命令?
A. systemctl start 服务 B. systemctl enable 服务 C. systemctl restart 服务 D. systemctl status 服务
答案:B
解析:enable 设置开机自启(创建软链接),start 仅立即启动一次;要开机自启且立即生效需 enable + start 配合。
常见问题
Q:start 和 enable 有什么区别
A:start 立即启动,enable 设置开机自动启动。
Q:怎么查看服务的运行状态
A:systemctl status 服务名。
Q:怎么让服务开机自启并立即启动
A:systemctl enable --now 服务名。
相关知识
教材出处:RH124 第9章 服务与守护进程(systemd)