通常会监听一个窗口
后台进程又称为守护进程,服务的本质就是进程。
service管理指令
service 服务名 [start|stop|restart|reload|status]
在centos7.0之后,使用的是 systemctl
案例
//查看当前防火墙状况,关闭和重启防火墙、
service iptables status
//关闭
service iptables stop
service iptables status
细节
这种方式只是 立即 临时生效。
通过telnet指令查看linux某个端口是否在监听,并且可以访问
dos
telnet ip 端口
telnet 192.168.....
查看服务名
方式一
使用setup->系统服务
带星号会自动启动
方式二
/etc/init
//可以列出目前系统有哪些服务
ls -l /etc/init.d/
服务的运行级别
系统常见有7种运行级别
查看或修改默认级别
vi /etc/inittab
常见运行级别
0:系统停机状态
1:单用户工作状态
2:多用户状态,不支持网络
3:完全的多用户状态
4:系统未使用,保留
5、进入图形界面
6、系统正常关闭并重启
chkconfig指令
可以给各个运行级别设置自启动/关闭
chkconfig --list
chkconfig --list|grep sshd
或者、
chkconfig iptables --list
chkconfig --level 5 服务名 on/off
chkconfig --level 5 sshd off
细节
chkconfig 重新设置服务后,自启动或关闭,需要重启机器reboot才能生效。
案例1
显示当前系统所有服务各个运行级别的运行状态
chkconfig --list
案例2
查看sshd服务的运行状态
service sshd status
案例6
在所有运行级别下,开启防火墙
chkconfig iptables on