单选题
运维人员需要让RHEL 9系统上的httpd服务开机自动启动,并立即启动该服务。他执行systemctl start httpd后服务运行正常,但重启后服务未启动。为设置开机自启,应执行哪条命令?
A. systemctl status httpd
B. systemctl restart httpd
C. systemctl enable httpd
D. systemctl start --now httpd
正确答案:C
依据systemctl(1),systemctl enable httpd会创建指向multi-user.target.wants的符号链接实现开机自启;start仅本次启动,restart与status不改变开机启动状态,enable --now才能同时启动并自启。
单选题
某企业的RHEL 8服务器上运行着httpd服务,管理员小刘需要设置该服务在系统启动时自动运行。他应该使用哪个命令来实现?
A. chkconfig httpd on
B. service httpd start
C. systemctl enable httpd
D. systemctl start httpd
正确答案:C
systemctl enable命令用于设置服务开机自启动,是systemd管理服务的标准方式。根据systemctl(1)手册页,enable会创建符号链接使服务在启动时激活。systemctl start仅启动服务不设置自启动,service和chkconfig是SysVinit时代的旧命令,在RHEL 7+中虽兼容但非推荐方式。