查看服务的方法:/etc/init.d/服务名
[root@hadoop100 init.d]# pwd
/etc/init.d
[root@hadoop100 init.d]# ls -al
如果是centOS7
显示一个服务的状态:systemctl status firewalld.service
关闭一个服务:systemctl stop firewalld.service后
启动一个服务:systemctl start firewalld.service
重启一个服务:systemctl restart firewalld.service
在开机时启用一个服务:systemctl enable firewalld.service
在开机时禁用一个服务:systemctl disable firewalld.service
查看服务是否开机启动:systemctl is-enabled firewalld.service
查看防火墙是否启动
查看已启动的服务列表:systemctl list-unit-files|grep enable
如果是centOS7以下版本
service 服务名 status (功能描述:查看服务状态)
service 服务名 stop (功能描述:关闭服务)
service 服务名 start (功能描述:开启服务)
service 服务名 restart (功能描述:重新启动服务)
service --status-all(查看系统中所有的后台服务)
案例实操
(1)查看网络服务的状态
[root@hadoop100 桌面]#service network status
(2)停止网络服务
[root@hadoop100 桌面]#service network stop
(3)启动网络服务
[root@hadoop100 桌面]#service network start
(4)重启网络服务
[root@hadoop100 桌面]#service network restart
(5)查看系统中所有的后台服务
[root@hadoop100 桌面]#service --status-all
chkconfig (功能描述:查看所有服务器自启配置)
chkconfig 服务名 off (功能描述:关掉指定服务的自动启动)
chkconfig 服务名 on (功能描述:开启指定服务的自动启动)
chkconfig 服务名 --list (功能描述:查看服务开机启动状态)
下面未试过,做个笔记
面说下CentOS7和6的默认防火墙的区别
CentOS 7默认使用的是firewall作为防火墙,使用iptables必须重新设置一下
1、直接关闭防火墙
systemctl stop firewalld.service
#停止firewall
systemctl disable firewalld.service
#禁止firewall开机启动