单选题
管理员小李用 systemctl 管理服务,希望某服务在系统启动时自动运行,且当前立即启动。下列哪条命令能同时满足这两个要求?
A. systemctl enable --now 服务名
B. systemctl start 服务名
C. systemctl status 服务名
D. systemctl enable 服务名
正确答案:A
依据 systemctl(1) 手册,enable 只创建开机自启链接不启动服务,start 只启动不设自启,而 enable --now 等价于 enable 加 start,可同时完成开机自启与立即启动。
单选题
系统管理员小张在RHEL 9服务器上部署Web服务,需要让 httpd 服务开机自动启动,并立即启动该服务。下列哪组命令能同时满足这两个要求?
A. systemctl enable httpd; service httpd restart
B. systemctl enable --now httpd
C. systemctl start httpd && systemctl enable httpd
D. systemctl preset httpd && systemctl start httpd
正确答案:B
systemctl(1) 手册页说明 enable --now 等价于同时执行 enable 和 start,一步完成开机自启与立即启动;选项C虽可行但非单组命令,选项D的 preset 按预设策略启停,不保证启用。