一、service命令是什么?
service命令用于对系统服务进行管理,比如
- 启动(start)
- 停止(stop)
- 重启(restart)
- 查看状态(status)
service命令本身是一个shell脚本
它在/etc/init.d/目录查找指定的服务脚本,然后调用该服务脚本来完成任务。
二、 常用的service命令
格式 | 说明 |
---|---|
service | 打印指定服务的命令行使用帮助。 |
service start | 启动指定的系统服务 |
service stop | 停止指定的系统服务 |
service restart | 重新启动指定的系统服务,即先停止(stop),然后再启动(start)。 |
三、其他与service相关命令
命令 | 说明 |
---|---|
chkconfig | 查看、设置服务的运行级别 |
ntsysv | 直观方便的设置各个服务是否自动启动 |
四、firewalld的基本使用
Linux服务管理 之 开启/关闭防火墙
systemctl是CentOS7的服务管理工具中主要的工具
它融合之前service和chkconfig的功能于一体。
启动:systemctl start firewalld
关闭:systemctl stop firewalld
查看状态:systemctl status firewalld
开机禁用:systemctl disable firewalld
开机启用:systemctl enable firewalld