单选题
管理员小李发现RHEL 9服务器上httpd服务无法开机自启,执行systemctl status httpd显示inactive(dead)。他需要让httpd在系统启动时自动运行。依据systemctl(1)手册,应执行哪条命令?
A. systemctl reload httpd
B. systemctl enable httpd
C. systemctl restart httpd
D. systemctl start httpd
正确答案:B
依据systemctl(1)手册,enable子命令用于创建符号链接使单元在开机时自动启动;start仅启动当前会话,restart用于重启,reload用于重载配置。要设置开机自启必须使用systemctl enable httpd。
单选题
某公司运维小赵在RHEL 9服务器上部署内部应用,需要让服务appsvc在系统启动时自动运行,且服务进程异常退出后能自动重启。他应使用systemctl的哪个子命令启用该服务?
A. systemctl start appsvc
B. systemctl enable appsvc
C. systemctl reload appsvc
D. systemctl restart appsvc
正确答案:B
依据 systemctl(1)手册,enable子命令创建符号链接使服务开机自启,配合单元文件中Restart=on-failure实现异常重启;start仅本次启动,reload为重载配置,restart为重启进程。