单选题
运维小王需要让Web服务httpd在系统启动时自动运行,并在当前立即启动。在RHEL9上他应依次执行的两条命令是?
A. systemctl mask httpd;systemctl start httpd
B. systemctl enable httpd;systemctl start httpd
C. chkconfig httpd on;service httpd start
D. systemctl start httpd;systemctl enable httpd
正确答案:B
依据systemctl(1),enable建立开机自启的符号链接,start立即启动服务;chkconfig与service属旧版SysV工具,mask表示禁止启动,顺序上先enable再start符合题意。
单选题
小王在RHEL 8服务器上安装httpd后,希望服务开机自启并立即启动。下列命令组合正确的是?
A. chkconfig httpd on 与 systemctl start httpd
B. systemctl start httpd 与 systemctl enable httpd
C. systemctl enable httpd 与 systemctl start httpd
D. service httpd enable 与 service httpd start
正确答案:C
依据 systemctl(1) 手册,enable 创建开机自启符号链接,start 立即启动单元;RHEL 8 已移除 chkconfig 对 systemd 单元的支持,service 命令仅为兼容包装,正确做法是 systemctl enable 与 start。
单选题
管理员小李需要让服务器上的httpd服务开机自动启动,并在不重启的情况下立即启动该服务。下列systemctl命令组合中正确的是哪一项?
A. systemctl start httpd 与 systemctl enable httpd 等价于 systemctl restart httpd
B. systemctl enable httpd 与 systemctl reload httpd
C. systemctl enable httpd 与 systemctl start httpd
D. systemctl daemon-reload 与 systemctl start httpd
正确答案:C
依据 systemctl(1) man page,enable 子命令用于创建开机自启的符号链接,start 子命令用于立即启动服务;daemon-reload 仅重新加载 unit 配置文件,不会启动服务,reload 只让运行中的服务重读配置,不能实现开机自启。